Ignore:
Timestamp:
Feb 28, 2017, 1:31:46 AM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler
Children:
81f738e
Parents:
8b7cdba
Message:

python/ext/py-sink.c: add 'with' interface (PEP 343)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-sink.c

    r8b7cdba rfcb6e8c  
    204204}
    205205
     206static char Pyaubio_sink_enter_doc[] = "";
     207static PyObject* Pyaubio_sink_enter(Py_sink *self, PyObject *unused) {
     208  Py_INCREF(self);
     209  return (PyObject*)self;
     210}
     211
     212static char Pyaubio_sink_exit_doc[] = "";
     213static PyObject* Pyaubio_sink_exit(Py_sink *self, PyObject *unused) {
     214  return Pyaubio_sink_close(self, unused);
     215}
     216
    206217static PyMethodDef Py_sink_methods[] = {
    207218  {"do", (PyCFunction) Py_sink_do, METH_VARARGS, Py_sink_do_doc},
    208219  {"do_multi", (PyCFunction) Py_sink_do_multi, METH_VARARGS, Py_sink_do_multi_doc},
    209220  {"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},
    210225  {NULL} /* sentinel */
    211226};
Note: See TracChangeset for help on using the changeset viewer.