2 #include "PyStdout.hxx"
3 #include <structmember.h>
17 PyStdOut_dealloc(PyStdOut *self)
23 PyStdOut_write(PyStdOut *self, PyObject *args)
27 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
31 *(self->out)=*(self->out)+c;
37 static PyMethodDef PyStdOut_methods[] = {
38 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
39 PyDoc_STR("write(string) -> None")},
40 {NULL, NULL} /* sentinel */
43 static PyMemberDef PyStdOut_memberlist[] = {
44 {"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
45 "flag indicating that a space needs to be printed; used by print"},
49 static PyTypeObject PyStdOut_Type = {
50 /* The ob_type field must be initialized in the module init function
51 * to be portable to Windows without using C++. */
52 PyObject_HEAD_INIT(NULL)
55 sizeof(PyStdOut), /*tp_basicsize*/
58 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
70 PyObject_GenericGetAttr, /*tp_getattro*/
71 /* softspace is writable: we must supply tp_setattro */
72 PyObject_GenericSetAttr, /* tp_setattro */
74 Py_TPFLAGS_DEFAULT, /*tp_flags*/
79 0, /*tp_weaklistoffset*/
82 PyStdOut_methods, /*tp_methods*/
83 PyStdOut_memberlist, /*tp_members*/
98 #define PyStdOut_Check(v) ((v)->ob_type == &PyStdOut_Type)
100 PyObject * newPyStdOut( std::string& out )
103 self = PyObject_New(PyStdOut, &PyStdOut_Type);
108 return (PyObject*)self;