From: NeilBrown Date: Mon, 25 Jan 2016 05:41:24 +0000 (+1100) Subject: python: add mark.dup() X-Git-Tag: lca2016~5 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=3167dc3af505c9e1abb8f914034982e1e69a36bf;p=edlib.git python: add mark.dup() Signed-off-by: NeilBrown --- diff --git a/lang-python.c b/lang-python.c index b601e637..665a0226 100644 --- a/lang-python.c +++ b/lang-python.c @@ -831,6 +831,20 @@ static PyObject *Mark_next_any(Mark *self) return Py_None; } +static PyObject *Mark_dup(Mark *self) +{ + struct mark *new; + if (!self->mark) { + PyErr_SetString(PyExc_TypeError, "Mark is NULL"); + return NULL; + } + new = mark_dup(self->mark, 0); + if (new) + return Mark_Frommark(new); + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef mark_methods[] = { {"to_mark", (PyCFunction)Mark_to_mark, METH_VARARGS, "Move one mark to another"}, @@ -840,6 +854,8 @@ static PyMethodDef mark_methods[] = { "previous vmark"}, {"next_any", (PyCFunction)Mark_next_any, METH_NOARGS, "next any_mark"}, + {"dup", (PyCFunction)Mark_dup, METH_NOARGS, + "duplicate a mark, preserving type"}, {NULL} };