Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -203,10 +203,25 @@ Pyaubio_sink_close (Py_sink *self, PyObject *unused) · 202 unmodified lines | ||
| 203 | 203 | Py_RETURN_NONE; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | +static char Pyaubio_sink_enter_doc[] = ""; | |
| 207 | +static PyObject* Pyaubio_sink_enter(Py_sink *self, PyObject *unused) { | |
| 208 | + Py_INCREF(self); | |
| 209 | + return (PyObject*)self; | |
| 210 | +} | |
| 211 | + | |
| 212 | +static char Pyaubio_sink_exit_doc[] = ""; | |
| 213 | +static PyObject* Pyaubio_sink_exit(Py_sink *self, PyObject *unused) { | |
| 214 | + return Pyaubio_sink_close(self, unused); | |
| 215 | +} | |
| 216 | + | |
| 206 | 217 | static PyMethodDef Py_sink_methods[] = { |
| 207 | 218 | {"do", (PyCFunction) Py_sink_do, METH_VARARGS, Py_sink_do_doc}, |
| 208 | 219 | {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS, Py_sink_do_multi_doc}, |
| 209 | 220 | {"close", (PyCFunction) Pyaubio_sink_close, METH_NOARGS, Py_sink_close_doc}, |
| 221 | + {"__enter__", (PyCFunction)Pyaubio_sink_enter, METH_NOARGS, | |
| 222 | + Pyaubio_sink_enter_doc}, | |
| 223 | + {"__exit__", (PyCFunction)Pyaubio_sink_exit, METH_VARARGS, | |
| 224 | + Pyaubio_sink_exit_doc}, | |
| 210 | 225 | {NULL} /* sentinel */ |
| 211 | 226 | }; |
| 212 | 227 | |