Update path.c

This commit is contained in:
Rithvik 2021-12-11 21:21:30 +05:30 committed by GitHub
parent cc927343da
commit 434ada1b76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -439,7 +439,6 @@ path_setitem(PyPathObject *self, Py_ssize_t i, PyObject *op) {
return 0; return 0;
} }
static PyObject * static PyObject *
path_tolist(PyPathObject *self, PyObject *args) { path_tolist(PyPathObject *self, PyObject *args) {
PyObject *list; PyObject *list;
@ -449,7 +448,6 @@ path_tolist(PyPathObject *self, PyObject *args) {
if (!PyArg_ParseTuple(args, "|i:tolist", &flat)) { if (!PyArg_ParseTuple(args, "|i:tolist", &flat)) {
return NULL; return NULL;
} }
if (flat) { if (flat) {
list = PyList_New(self->count * 2); list = PyList_New(self->count * 2);
for (i = 0; i < self->count * 2; i++) { for (i = 0; i < self->count * 2; i++) {
@ -471,30 +469,23 @@ path_tolist(PyPathObject *self, PyObject *args) {
PyList_SetItem(list, i, item); PyList_SetItem(list, i, item);
} }
} }
return list; return list;
error: error:
Py_DECREF(list); Py_DECREF(list);
return NULL; return NULL;
} }
static PyObject * static PyObject *
path_transform(PyPathObject *self, PyObject *args) { path_transform(PyPathObject *self, PyObject *args) {
/* Apply affine transform to coordinate set */ /* Apply affine transform to coordinate set */
Py_ssize_t i; Py_ssize_t i;
double *xy; double *xy;
double a, b, c, d, e, f; double a, b, c, d, e, f;
double wrap = 0.0; double wrap = 0.0;
if (!PyArg_ParseTuple( if (!PyArg_ParseTuple(
args, "(dddddd)|d:transform", &a, &b, &c, &d, &e, &f, &wrap)) { args, "(dddddd)|d:transform", &a, &b, &c, &d, &e, &f, &wrap)) {
return NULL; return NULL;
} }
xy = self->xy; xy = self->xy;
/* transform the coordinate set */ /* transform the coordinate set */
if (b == 0.0 && d == 0.0) { if (b == 0.0 && d == 0.0) {
/* scaling */ /* scaling */
@ -518,11 +509,9 @@ path_transform(PyPathObject *self, PyObject *args) {
xy[i + i] = fmod(xy[i + i], wrap); xy[i + i] = fmod(xy[i + i], wrap);
} }
} }
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
static struct PyMethodDef methods[] = { static struct PyMethodDef methods[] = {
{"getbbox", (PyCFunction)path_getbbox, METH_VARARGS}, {"getbbox", (PyCFunction)path_getbbox, METH_VARARGS},
{"tolist", (PyCFunction)path_tolist, METH_VARARGS}, {"tolist", (PyCFunction)path_tolist, METH_VARARGS},
@ -531,14 +520,11 @@ static struct PyMethodDef methods[] = {
{"transform", (PyCFunction)path_transform, METH_VARARGS}, {"transform", (PyCFunction)path_transform, METH_VARARGS},
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
static PyObject * static PyObject *
path_getattr_id(PyPathObject *self, void *closure) { path_getattr_id(PyPathObject *self, void *closure) {
return Py_BuildValue("n", (Py_ssize_t)self->xy); return Py_BuildValue("n", (Py_ssize_t)self->xy);
} }
static struct PyGetSetDef getsetters[] = {{"id", (getter)path_getattr_id}, {NULL}}; static struct PyGetSetDef getsetters[] = {{"id", (getter)path_getattr_id}, {NULL}};
static PyObject * static PyObject *
path_subscript(PyPathObject *self, PyObject *item) { path_subscript(PyPathObject *self, PyObject *item) {
if (PyIndex_Check(item)) { if (PyIndex_Check(item)) {
@ -574,7 +560,6 @@ path_subscript(PyPathObject *self, PyObject *item) {
return NULL; return NULL;
} }
} }
static PySequenceMethods path_as_sequence = { static PySequenceMethods path_as_sequence = {
(lenfunc)path_len, /*sq_length*/ (lenfunc)path_len, /*sq_length*/
(binaryfunc)0, /*sq_concat*/ (binaryfunc)0, /*sq_concat*/