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.
This commit is contained in:
		| @@ -188,7 +188,13 @@ static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, P | ||||
|   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | ||||
|  | ||||
|   static const char *_keywords[] = {"restore", NULL}; | ||||
|   static _PyArg_Parser _parser = {"|$O&:unbind", _keywords, 0}; | ||||
|   static _PyArg_Parser _parser = { | ||||
|       "|$" /* Optional keyword only arguments. */ | ||||
|       "O&" /* `restore` */ | ||||
|       ":unbind", | ||||
|       _keywords, | ||||
|       0, | ||||
|   }; | ||||
|   if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &restore)) { | ||||
|     return NULL; | ||||
|   } | ||||
| @@ -216,7 +222,15 @@ static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self), | ||||
|   char err_out[256]; | ||||
|  | ||||
|   static const char *_keywords[] = {"width", "height", "format", NULL}; | ||||
|   static _PyArg_Parser _parser = {"ii|$O&:GPUOffScreen.__new__", _keywords, 0}; | ||||
|   static _PyArg_Parser _parser = { | ||||
|       "i"  /* `width` */ | ||||
|       "i"  /* `height` */ | ||||
|       "|$" /* Optional keyword only arguments. */ | ||||
|       "O&" /* `format` */ | ||||
|       ":GPUOffScreen.__new__", | ||||
|       _keywords, | ||||
|       0, | ||||
|   }; | ||||
|   if (!_PyArg_ParseTupleAndKeywordsFast( | ||||
|           args, kwds, &_parser, &width, &height, PyC_ParseStringEnum, &pygpu_textureformat)) { | ||||
|     return NULL; | ||||
| @@ -309,16 +323,29 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar | ||||
|  | ||||
|   BPY_GPU_OFFSCREEN_CHECK_OBJ(self); | ||||
|  | ||||
|   static const char *_keywords[] = {"scene", | ||||
|                                     "view_layer", | ||||
|                                     "view3d", | ||||
|                                     "region", | ||||
|                                     "view_matrix", | ||||
|                                     "projection_matrix", | ||||
|                                     "do_color_management", | ||||
|                                     NULL}; | ||||
|  | ||||
|   static _PyArg_Parser _parser = {"OOOOO&O&|$O&:draw_view3d", _keywords, 0}; | ||||
|   static const char *_keywords[] = { | ||||
|       "scene", | ||||
|       "view_layer", | ||||
|       "view3d", | ||||
|       "region", | ||||
|       "view_matrix", | ||||
|       "projection_matrix", | ||||
|       "do_color_management", | ||||
|       NULL, | ||||
|   }; | ||||
|   static _PyArg_Parser _parser = { | ||||
|       "O"  /* `scene` */ | ||||
|       "O"  /* `view_layer` */ | ||||
|       "O"  /* `view3d` */ | ||||
|       "O"  /* `region` */ | ||||
|       "O&" /* `view_matrix` */ | ||||
|       "O&" /* `projection_matrix` */ | ||||
|       "|$" /* Optional keyword only arguments. */ | ||||
|       "O&" /* `do_color_management` */ | ||||
|       ":draw_view3d", | ||||
|       _keywords, | ||||
|       0, | ||||
|   }; | ||||
|   if (!_PyArg_ParseTupleAndKeywordsFast(args, | ||||
|                                         kwds, | ||||
|                                         &_parser, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user