[Bf-blender-cvs] [067ffe96a4f] temp-T96710-pbvh-pixels: Cleanup: separate format-units for Python argument parsing
Campbell Barton
noreply at git.blender.org
Fri Apr 8 11:07:50 CEST 2022
Commit: 067ffe96a4fa5fa8212488607818398db2b4d964
Author: Campbell Barton
Date: Fri Apr 8 09:41:28 2022 +1000
Branches: temp-T96710-pbvh-pixels
https://developer.blender.org/rB067ffe96a4fa5fa8212488607818398db2b4d964
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.
===================================================================
M source/blender/python/generic/imbuf_py_api.c
M source/blender/python/gpu/gpu_py_batch.c
M source/blender/python/gpu/gpu_py_element.c
M source/blender/python/gpu/gpu_py_framebuffer.c
M source/blender/python/gpu/gpu_py_offscreen.c
M source/blender/python/gpu/gpu_py_shader.c
M source/blender/python/gpu/gpu_py_texture.c
M source/blender/python/gpu/gpu_py_uniformbuffer.c
M source/blender/python/gpu/gpu_py_vertex_buffer.c
M source/blender/python/gpu/gpu_py_vertex_format.c
M source/blender/python/intern/bpy.c
M source/blender/python/intern/bpy_app_icons.c
M source/blender/python/intern/bpy_app_timers.c
M source/blender/python/intern/bpy_gizmo_wrap.c
M source/blender/python/intern/bpy_library_load.c
M source/blender/python/intern/bpy_library_write.c
M source/blender/python/intern/bpy_msgbus.c
M source/blender/python/intern/bpy_props.c
M source/blender/python/intern/bpy_rna.c
M source/blender/python/intern/bpy_rna_data.c
M source/blender/python/intern/bpy_rna_gizmo.c
M source/blender/python/intern/bpy_rna_id_collection.c
M source/blender/python/intern/bpy_utils_units.c
===================================================================
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c
index bfe25435eab..ef11d1ab32d 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -92,7 +92,14 @@ static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
struct PyC_StringEnum method = {method_items, FAST};
static const char *_keywords[] = {"size", "method", NULL};
- static _PyArg_Parser _parser = {"(ii)|$O&:resize", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "(ii)" /* `size` */
+ "|$" /* Optional keyword only arguments. */
+ "O&" /* `method` */
+ ":resize",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method)) {
return NULL;
@@ -130,7 +137,13 @@ static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
rcti crop;
static const char *_keywords[] = {"min", "max", NULL};
- static _PyArg_Parser _parser = {"(II)(II):crop", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "(II)" /* `min` */
+ "(II)" /* `max` */
+ ":crop",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kw, &_parser, &crop.xmin, &crop.ymin, &crop.xmax, &crop.ymax)) {
return NULL;
@@ -420,7 +433,12 @@ static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *k
{
int size[2];
static const char *_keywords[] = {"size", NULL};
- static _PyArg_Parser _parser = {"(ii):new", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "(ii)" /* `size` */
+ ":new",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &size[0], &size[1])) {
return NULL;
}
@@ -455,7 +473,12 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *
const char *filepath;
static const char *_keywords[] = {"filepath", NULL};
- static _PyArg_Parser _parser = {"s:load", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "s" /* `filepath` */
+ ":load",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filepath)) {
return NULL;
}
@@ -497,7 +520,14 @@ static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject
const char *filepath = NULL;
static const char *_keywords[] = {"image", "filepath", NULL};
- static _PyArg_Parser _parser = {"O!|$s:write", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "O!" /* `image` */
+ "|$" /* Optional keyword only arguments. */
+ "s" /* `filepath` */
+ ":write",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &Py_ImBuf_Type, &py_imb, &filepath)) {
return NULL;
}
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index 486601f4c86..232d4775746 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -60,7 +60,15 @@ static PyObject *pygpu_batch__tp_new(PyTypeObject *UNUSED(type), PyObject *args,
BPyGPUIndexBuf *py_indexbuf = NULL;
static const char *_keywords[] = {"type", "buf", "elem", NULL};
- static _PyArg_Parser _parser = {"|$O&O!O!:GPUBatch.__new__", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "|$" /* Optional keyword only arguments. */
+ "O&" /* `type` */
+ "O!" /* `buf` */
+ "O!" /* `elem` */
+ ":GPUBatch.__new__",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(args,
kwds,
&_parser,
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c
index af993539f18..f2836576659 100644
--- a/source/blender/python/gpu/gpu_py_element.c
+++ b/source/blender/python/gpu/gpu_py_element.c
@@ -40,7 +40,13 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar
GPUIndexBufBuilder builder;
static const char *_keywords[] = {"type", "seq", NULL};
- static _PyArg_Parser _parser = {"$O&O:IndexBuf.__new__", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "$O" /* `type` */
+ "&O" /* `seq` */
+ ":IndexBuf.__new__",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kwds, &_parser, PyC_ParseStringEnum, &prim_type, &seq)) {
return NULL;
diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c
index 5cc36a7b61b..2a7857b3059 100644
--- a/source/blender/python/gpu/gpu_py_framebuffer.c
+++ b/source/blender/python/gpu/gpu_py_framebuffer.c
@@ -278,7 +278,14 @@ static PyObject *pygpu_framebuffer__tp_new(PyTypeObject *UNUSED(self),
PyObject *depth_attachment = NULL;
PyObject *color_attachements = NULL;
static const char *_keywords[] = {"depth_slot", "color_slots", NULL};
- static _PyArg_Parser _parser = {"|$OO:GPUFrameBuffer.__new__", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "|$" /* Optional keyword only arguments. */
+ "O" /* `depth_slot` */
+ "O" /* `color_slots` */
+ ":GPUFrameBuffer.__new__",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kwds, &_parser, &depth_attachment, &color_attachements)) {
return NULL;
@@ -365,7 +372,15 @@ static PyObject *pygpu_framebuffer_clear(BPyGPUFrameBuffer *self, PyObject *args
PyObject *py_stencil = NULL;
static const char *_keywords[] = {"color", "depth", "stencil", NULL};
- static _PyArg_Parser _parser = {"|$OOO:clear", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "|$" /* Optional keyword only arguments. */
+ "O" /* `color` */
+ "O" /* `depth` */
+ "O" /* `stencil` */
+ ":clear",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &py_col, &py_depth, &py_stencil)) {
return NULL;
}
@@ -475,7 +490,20 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
static const char *_keywords[] = {
"x", "y", "xsize", "ysize", "channels", "slot", "format", "data", NULL};
- static _PyArg_Parser _parser = {"iiiiiIO&|$O!:read_color", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "i" /* `x` */
+ "i" /* `y` */
+ "i" /* `xsize` */
+ "i" /* `ysize` */
+ "i" /* `channels` */
+ "I" /* `slot` */
+ "O&" /* `format` */
+ "|$" /* Optional keyword only arguments. */
+ "O!" /* `data` */
+ ":read_color",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(args,
kwds,
&_parser,
@@ -559,7 +587,17 @@ static PyObject *pygpu_framebuffer_read_depth(BPyGPUFrameBuffer *self,
BPyGPUBuffer *py_buffer = NULL;
static const char *_keywords[] = {"x", "y", "xsize", "ysize", "data", NULL};
- static _PyArg_Parser _parser = {"iiii|$O!:read_depth", _keywords, 0};
+ static _PyArg_Parser _parser = {
+ "i" /* `x` */
+ "i" /* `y` */
+ "i" /* `xsize` */
+ "i" /* `ysize` */
+ "|$" /* Optional keyword only arguments. */
+ "O!" /* `data` */
+ ":read_depth",
+ _keywords,
+ 0,
+ };
if (!_PyArg_ParseTupleAndKeywordsFast(
args, kwds, &_parser, &x, &y, &w, &h, &BPyGPU_BufferType, &py_buffer)) {
return NULL;
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 32bfe47ef0b..b50f536da8a 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -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_ParseTupl
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list