Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -272,6 +272,18 @@ Pyaubio_source_seek (Py_source *self, PyObject *args) · 271 unmodified lines | ||
| 272 | 272 | Py_RETURN_NONE; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | +static char Pyaubio_source_enter_doc[] = ""; | |
| 276 | +static PyObject* Pyaubio_source_enter(Py_source *self, PyObject *unused) { | |
| 277 | + Py_INCREF(self); | |
| 278 | + return (PyObject*)self; | |
| 279 | +} | |
| 280 | + | |
| 281 | +static char Pyaubio_source_exit_doc[] = ""; | |
| 282 | +static PyObject* Pyaubio_source_exit(Py_source *self, PyObject *unused) { | |
| 283 | + Pyaubio_source_close(self, unused); | |
| 284 | + return Pyaubio_source_close(self, unused); | |
| 285 | +} | |
| 286 | + | |
| 275 | 287 | static PyMethodDef Py_source_methods[] = { |
| 276 | 288 | {"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate, |
| 277 | 289 | METH_NOARGS, Py_source_get_samplerate_doc}, |
| @@ -285,6 +297,10 @@ static PyMethodDef Py_source_methods[] = { · 7 unmodified lines | ||
| 285 | 297 | METH_NOARGS, Py_source_close_doc}, |
| 286 | 298 | {"seek", (PyCFunction) Pyaubio_source_seek, |
| 287 | 299 | METH_VARARGS, Py_source_seek_doc}, |
| 300 | + {"__enter__", (PyCFunction)Pyaubio_source_enter, METH_NOARGS, | |
| 301 | + Pyaubio_source_enter_doc}, | |
| 302 | + {"__exit__", (PyCFunction)Pyaubio_source_exit, METH_VARARGS, | |
| 303 | + Pyaubio_source_exit_doc}, | |
| 288 | 304 | {NULL} /* sentinel */ |
| 289 | 305 | }; |
| 290 | 306 | |