diff options
author | Campbell Barton <campbell@blender.org> | 2022-04-08 02:41:28 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-04-08 04:49:50 +0300 |
commit | 982aea88e0d74020c62c2054a45eeafa56c8ca30 (patch) | |
tree | 6215fe088028a0943ace5ea80e256b7a42132420 /source/blender/python/gpu/gpu_py_shader.c | |
parent | 87a3bf33564b035e4c2400098ea4932d5dfdba5d (diff) |
Cleanup: separate format-units for Python argument parsing
With the increased use of multi-character format units and keyword-only
arguments these are increasingly difficult to make sense of.
Split the string onto multiple lines, one per argument.
While verbose it's easier to understand and add new arguments.
Diffstat (limited to 'source/blender/python/gpu/gpu_py_shader.c')
-rw-r--r-- | source/blender/python/gpu/gpu_py_shader.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 43b26e05327..c74b3e173d1 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -96,8 +96,18 @@ static PyObject *pygpu_shader__tp_new(PyTypeObject *UNUSED(type), PyObject *args static const char *_keywords[] = { "vertexcode", "fragcode", "geocode", "libcode", "defines", "name", NULL}; - - static _PyArg_Parser _parser = {"ss|$ssss:GPUShader.__new__", _keywords, 0}; + static _PyArg_Parser _parser = { + "s" /* `vertexcode` */ + "s" /* `fragcode` */ + "|$" /* Optional keyword only arguments. */ + "s" /* `geocode` */ + "s" /* `libcode` */ + "s" /* `defines` */ + "s" /* `name` */ + ":GPUShader.__new__", + _keywords, + 0, + }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, @@ -751,7 +761,14 @@ static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg struct PyC_StringEnum pygpu_config = {pygpu_shader_config_items, GPU_SHADER_CFG_DEFAULT}; static const char *_keywords[] = {"shader_name", "config", NULL}; - static _PyArg_Parser _parser = {"O&|$O&:from_builtin", _keywords, 0}; + static _PyArg_Parser _parser = { + "O&" /* `shader_name` */ + "|$" /* Optional keyword only arguments. */ + "O&" /* `config` */ + ":from_builtin", + _keywords, + 0, + }; if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, |