Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8523
Modified Files:
Tag: py3k
win32file.i win32file_comm.cpp
Added Files:
Tag: py3k
win32file_comm.h
Log Message:
Move definitions for PyDCB and PyCOMSTAT into a header file
Call PyType_Ready for above types
--- NEW FILE: win32file_comm.h ---
// The communications related functions.
// The COMM port enhancements were added by Mark Hammond, and are
// (c) 2000-2001, ActiveState Tools Corp.
// The comms port helpers.
extern PyObject *PyWinObject_FromCOMSTAT(const COMSTAT *pCOMSTAT);
extern BOOL PyWinObject_AsCOMSTAT(PyObject *ob, COMSTAT **ppCOMSTAT, BOOL bNoneOK = TRUE);
extern BOOL PyWinObject_AsDCB(PyObject *ob, DCB **ppDCB, BOOL bNoneOK = TRUE);
extern PyObject *PyWinObject_FromDCB(const DCB *pDCB);
extern PyObject *PyWinMethod_NewDCB(PyObject *self, PyObject *args);
extern PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p);
extern BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p);
class PyDCB : public PyObject
{
public:
DCB *GetDCB() {return &m_DCB;}
PyDCB(void);
PyDCB(const DCB &);
~PyDCB();
/* Python support */
int compare(PyObject *ob);
static void deallocFunc(PyObject *ob);
static int compareFunc(PyObject *ob1, PyObject *ob2);
static PyObject *getattro(PyObject *self, PyObject *obname);
static int setattro(PyObject *self, PyObject *obname, PyObject *v);
static struct PyMemberDef members[];
static PyTypeObject type;
protected:
DCB m_DCB;
};
#define PyDCB_Check(x) ((x)->ob_type==&PyDCB::type)
////////////////////////////////////////////////////////////////
//
// COMSTAT object.
//
////////////////////////////////////////////////////////////////
class PyCOMSTAT : public PyObject
{
public:
COMSTAT *GetCOMSTAT() {return &m_COMSTAT;}
PyCOMSTAT(void);
PyCOMSTAT(const COMSTAT &);
~PyCOMSTAT();
/* Python support */
int compare(PyObject *ob);
static void deallocFunc(PyObject *ob);
static int compareFunc(PyObject *ob1, PyObject *ob2);
static PyObject *getattro(PyObject *self, PyObject *obname);
static int setattro(PyObject *self, PyObject *obname, PyObject *v);
static struct PyMemberDef members[];
static PyTypeObject type;
protected:
COMSTAT m_COMSTAT;
};
#define PyCOMSTAT_Check(x) ((x)->ob_type==&PyCOMSTAT::type)
Index: win32file_comm.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file_comm.cpp,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -C2 -d -r1.5.4.1 -r1.5.4.2
*** win32file_comm.cpp 29 Aug 2008 04:59:26 -0000 1.5.4.1
--- win32file_comm.cpp 27 Sep 2008 18:07:41 -0000 1.5.4.2
***************
*** 9,12 ****
--- 9,13 ----
#include "PyWinTypes.h"
#include "PyWinObjects.h"
+ #include "win32file_comm.h"
// Small enough we can use a tuple!
***************
*** 19,23 ****
PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p)
{
! return Py_BuildValue("iiiii",
p->ReadIntervalTimeout,
p->ReadTotalTimeoutMultiplier,
--- 20,24 ----
PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p)
{
! return Py_BuildValue("kkkkk",
p->ReadIntervalTimeout,
p->ReadTotalTimeoutMultiplier,
***************
*** 29,33 ****
BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p)
{
! return PyArg_ParseTuple(ob, "iiiii",
&p->ReadIntervalTimeout,
&p->ReadTotalTimeoutMultiplier,
--- 30,34 ----
BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p)
{
! return PyArg_ParseTuple(ob, "kkkkk",
&p->ReadIntervalTimeout,
&p->ReadTotalTimeoutMultiplier,
***************
*** 39,68 ****
static const char *szNeedIntAttr = "Attribute '%s' must be an integer";
- class PyDCB : public PyObject
- {
- public:
- DCB *GetDCB() {return &m_DCB;}
-
- PyDCB(void);
- PyDCB(const DCB &);
- ~PyDCB();
-
- /* Python support */
- int compare(PyObject *ob);
-
- static void deallocFunc(PyObject *ob);
- static int compareFunc(PyObject *ob1, PyObject *ob2);
-
- static PyObject *getattro(PyObject *self, PyObject *obname);
- static int setattro(PyObject *self, PyObject *obname, PyObject *v);
- static struct PyMemberDef members[];
- static PyTypeObject type;
-
- protected:
- DCB m_DCB;
- };
-
- #define PyDCB_Check(x) ((x)->ob_type==&PyDCB::type)
-
// @pymethod <o PyDCB>|win32file|DCB|Creates a new DCB object
PyObject *PyWinMethod_NewDCB(PyObject *self, PyObject *args)
--- 40,43 ----
***************
*** 120,125 ****
0, /* tp_call */
0, /* tp_str */
! PyDCB::getattro, /* tp_getattro */
! PyDCB::setattro, /* tp_setattro */
};
--- 95,120 ----
0, /* tp_call */
0, /* tp_str */
! PyDCB::getattro, /* tp_getattro */
! PyDCB::setattro, /* tp_setattro */
! 0, /*tp_as_buffer*/
! Py_TPFLAGS_DEFAULT, /* tp_flags */
! "Wraps a DCB struct", /* tp_doc */
! 0, /* tp_traverse */
! 0, /* tp_clear */
! 0, /* tp_richcompare */
! 0, /* tp_weaklistoffset */
! 0, /* tp_iter */
! 0, /* tp_iternext */
! 0, /* tp_methods */
! PyDCB::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 */
};
***************
*** 260,289 ****
//
////////////////////////////////////////////////////////////////
- class PyCOMSTAT : public PyObject
- {
- public:
- COMSTAT *GetCOMSTAT() {return &m_COMSTAT;}
-
- PyCOMSTAT(void);
- PyCOMSTAT(const COMSTAT &);
- ~PyCOMSTAT();
-
- /* Python support */
- int compare(PyObject *ob);
-
- static void deallocFunc(PyObject *ob);
- static int compareFunc(PyObject *ob1, PyObject *ob2);
-
- static PyObject *getattro(PyObject *self, PyObject *obname);
- static int setattro(PyObject *self, PyObject *obname, PyObject *v);
- static struct PyMemberDef members[];
- static PyTypeObject type;
-
- protected:
- COMSTAT m_COMSTAT;
- };
-
- #define PyCOMSTAT_Check(x) ((x)->ob_type==&PyCOMSTAT::type)
-
// @pymethod <o PyCOMSTAT>|win32file|COMSTAT|Creates a new COMSTAT object
PyObject *PyWinMethod_NewCOMSTAT(PyObject *self, PyObject *args)
--- 255,258 ----
***************
*** 341,344 ****
--- 310,333 ----
PyCOMSTAT::getattro, /* tp_getattr */
PyCOMSTAT::setattro, /* tp_setattr */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ "Wraps a COMMSTAT struct", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ PyCOMSTAT::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 */
};
Index: win32file.i
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v
retrieving revision 1.93.2.1
retrieving revision 1.93.2.2
diff -C2 -d -r1.93.2.1 -r1.93.2.2
*** win32file.i 29 Aug 2008 04:59:26 -0000 1.93.2.1
--- win32file.i 27 Sep 2008 18:07:41 -0000 1.93.2.2
***************
*** 46,49 ****
--- 46,50 ----
#define NEED_PYWINOBJECTS_H
+ #include "win32file_comm.h"
%}
***************
*** 2397,2416 ****
#endif // MS_WINCE
- // The communications related functions.
- // The COMM port enhancements were added by Mark Hammond, and are
- // (c) 2000-2001, ActiveState Tools Corp.
-
- %{
- // The comms port helpers.
- extern PyObject *PyWinObject_FromCOMSTAT(const COMSTAT *pCOMSTAT);
- extern BOOL PyWinObject_AsCOMSTAT(PyObject *ob, COMSTAT **ppCOMSTAT, BOOL bNoneOK = TRUE);
- extern BOOL PyWinObject_AsDCB(PyObject *ob, DCB **ppDCB, BOOL bNoneOK = TRUE);
- extern PyObject *PyWinObject_FromDCB(const DCB *pDCB);
- extern PyObject *PyWinMethod_NewDCB(PyObject *self, PyObject *args);
- extern PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p);
- extern BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p);
-
- %}
-
%native (DCB) PyWinMethod_NewDCB;
--- 2398,2401 ----
***************
*** 5223,5228 ****
#endif
! if (PyType_Ready(&FindFileIterator_Type) == -1)
RETURN_ERROR;
if (PyDict_SetItemString(d, "error", PyWinExc_ApiError) == -1)
RETURN_ERROR;
--- 5208,5216 ----
#endif
! if (PyType_Ready(&FindFileIterator_Type) == -1
! ||PyType_Ready(&PyDCB::type) == -1
! ||PyType_Ready(&PyCOMSTAT::type) == -1)
RETURN_ERROR;
+
if (PyDict_SetItemString(d, "error", PyWinExc_ApiError) == -1)
RETURN_ERROR;
|