diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-04-26 16:18:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-04-26 16:18:00 +0300 |
commit | 29e96158b9939035ad46e77a07f29807de843ec2 (patch) | |
tree | 08937c836cdef1227e19dbe3e7768483764ffbca /source/blender/python/intern/bpy_app_icons.c | |
parent | 05c9ddb2d62cde49aa3ec0b1523ed7243933e17f (diff) |
Icons: correct arg parsing
Use _PyArg_ParseTupleAndKeywordsFast
Diffstat (limited to 'source/blender/python/intern/bpy_app_icons.c')
-rw-r--r-- | source/blender/python/intern/bpy_app_icons.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/source/blender/python/intern/bpy_app_icons.c b/source/blender/python/intern/bpy_app_icons.c index 6d3b50d5688..4bd059dd295 100644 --- a/source/blender/python/intern/bpy_app_icons.c +++ b/source/blender/python/intern/bpy_app_icons.c @@ -51,13 +51,16 @@ PyDoc_STRVAR(bpy_app_icons_new_triangles_doc, " :return: Unique icon value (pass to interface ``icon_value`` argument).\n" " :rtype: int\n" ); -static PyObject *bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *args) +static PyObject *bpy_app_icons_new_triangles(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { /* bytes */ uchar coords_range[2]; PyObject *py_coords, *py_colors; - if (!PyArg_ParseTuple( - args, "(BB)SS:new_triangles", + + static const char *_keywords[] = {"range", "coords", "colors", NULL}; + static _PyArg_Parser _parser = {"(BB)SS:new_triangles", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, &coords_range[0], &coords_range[1], &py_coords, &py_colors)) { return NULL; @@ -103,12 +106,15 @@ PyDoc_STRVAR(bpy_app_icons_new_triangles_from_file_doc, " :return: Unique icon value (pass to interface ``icon_value`` argument).\n" " :rtype: int\n" ); -static PyObject *bpy_app_icons_new_triangles_from_file(PyObject *UNUSED(self), PyObject *args) +static PyObject *bpy_app_icons_new_triangles_from_file(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { /* bytes */ char *filename; - if (!PyArg_ParseTuple( - args, "s:new_triangles_from_file", + + static const char *_keywords[] = {"filename", NULL}; + static _PyArg_Parser _parser = {"s:new_triangles_from_file", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, &filename)) { return NULL; @@ -128,13 +134,14 @@ PyDoc_STRVAR(bpy_app_icons_release_doc, "\n" " Release the icon.\n" ); -static PyObject *bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args) +static PyObject *bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args, PyObject *kw) { int icon_id; - static _PyArg_Parser _parser = {"i:release", NULL, 0}; + static const char *_keywords[] = {"icon_id", NULL}; + static _PyArg_Parser _parser = {"i:release", _keywords, 0}; if (!_PyArg_ParseTupleAndKeywordsFast( - args, NULL, &_parser, - &icon_id)) + args, kw, &_parser, + &icon_id)) { return NULL; } @@ -147,9 +154,12 @@ static PyObject *bpy_app_icons_release(PyObject *UNUSED(self), PyObject *args) } static struct PyMethodDef M_AppIcons_methods[] = { - {"new_triangles", (PyCFunction)bpy_app_icons_new_triangles, METH_VARARGS, bpy_app_icons_new_triangles_doc}, - {"new_triangles_from_file", (PyCFunction)bpy_app_icons_new_triangles_from_file, METH_VARARGS, bpy_app_icons_new_triangles_from_file_doc}, - {"release", (PyCFunction)bpy_app_icons_release, METH_VARARGS, bpy_app_icons_release_doc}, + {"new_triangles", (PyCFunction)bpy_app_icons_new_triangles, + METH_VARARGS | METH_KEYWORDS, bpy_app_icons_new_triangles_doc}, + {"new_triangles_from_file", (PyCFunction)bpy_app_icons_new_triangles_from_file, + METH_VARARGS | METH_KEYWORDS, bpy_app_icons_new_triangles_from_file_doc}, + {"release", (PyCFunction)bpy_app_icons_release, + METH_VARARGS | METH_KEYWORDS, bpy_app_icons_release_doc}, {NULL, NULL, 0, NULL} }; |