From 1069a70e81e93dda97c53b45099013e70c7199d5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 29 Dec 2017 14:29:50 +0000 Subject: [PATCH] python: Impement setting the name of an AS Signed-off-by: Michael Tremer --- src/python/as.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/python/as.c b/src/python/as.c index ca0af47..3b28648 100644 --- a/src/python/as.c +++ b/src/python/as.c @@ -80,6 +80,21 @@ static PyObject* AS_get_name(ASObject* self) { return PyUnicode_FromString(name); } +static int AS_set_name(ASObject* self, PyObject* args) { + const char* name = NULL; + + if (!PyArg_ParseTuple(args, "s", &name)) + return -1; + + int r = loc_as_set_name(self->as, name); + if (r) { + PyErr_Format(PyExc_ValueError, "Could not set name: %s", name); + return r; + } + + return 0; +} + static PyObject* AS_richcompare(ASObject* self, ASObject* other, int op) { int r = loc_as_cmp(self->as, other->as); @@ -107,7 +122,7 @@ static struct PyGetSetDef AS_getsetters[] = { { "name", (getter)AS_get_name, - NULL, + (setter)AS_set_name, NULL, NULL, }, -- 2.39.2