projects
/
aubio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
cc469dd
)
python/ext/py-source.c: add with interface (PEP 343)
author
Paul Brossier
<piem@piem.org>
Sun, 26 Feb 2017 22:47:19 +0000
(23:47 +0100)
committer
Paul Brossier
<piem@piem.org>
Sun, 26 Feb 2017 22:47:19 +0000
(23:47 +0100)
python/ext/py-source.c
patch
|
blob
|
history
diff --git
a/python/ext/py-source.c
b/python/ext/py-source.c
index
8350904
..
f8dd3aa
100644
(file)
--- a/
python/ext/py-source.c
+++ b/
python/ext/py-source.c
@@
-272,6
+272,18
@@
Pyaubio_source_seek (Py_source *self, PyObject *args)
Py_RETURN_NONE;
}
Py_RETURN_NONE;
}
+static char Pyaubio_source_enter_doc[] = "";
+static PyObject* Pyaubio_source_enter(Py_source *self, PyObject *unused) {
+ Py_INCREF(self);
+ return (PyObject*)self;
+}
+
+static char Pyaubio_source_exit_doc[] = "";
+static PyObject* Pyaubio_source_exit(Py_source *self, PyObject *unused) {
+ Pyaubio_source_close(self, unused);
+ return Pyaubio_source_close(self, unused);
+}
+
static PyMethodDef Py_source_methods[] = {
{"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,
METH_NOARGS, Py_source_get_samplerate_doc},
static PyMethodDef Py_source_methods[] = {
{"get_samplerate", (PyCFunction) Pyaubio_source_get_samplerate,
METH_NOARGS, Py_source_get_samplerate_doc},
@@
-285,6
+297,10
@@
static PyMethodDef Py_source_methods[] = {
METH_NOARGS, Py_source_close_doc},
{"seek", (PyCFunction) Pyaubio_source_seek,
METH_VARARGS, Py_source_seek_doc},
METH_NOARGS, Py_source_close_doc},
{"seek", (PyCFunction) Pyaubio_source_seek,
METH_VARARGS, Py_source_seek_doc},
+ {"__enter__", (PyCFunction)Pyaubio_source_enter, METH_NOARGS,
+ Pyaubio_source_enter_doc},
+ {"__exit__", (PyCFunction)Pyaubio_source_exit, METH_VARARGS,
+ Pyaubio_source_exit_doc},
{NULL} /* sentinel */
};
{NULL} /* sentinel */
};