[Bf-blender-cvs] [1a827e0564b] blender2.8: Cleanup: move params into their own struct

Campbell Barton noreply at git.blender.org
Thu Oct 25 08:22:00 CEST 2018


Commit: 1a827e0564b7465320467b8eb508ed073ae5781f
Author: Campbell Barton
Date:   Thu Oct 25 17:20:26 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB1a827e0564b7465320467b8eb508ed073ae5781f

Cleanup: move params into their own struct

===================================================================

M	source/blender/python/intern/bpy_rna_callback.c

===================================================================

diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index c0cfbab75dd..521fc518c62 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -361,8 +361,6 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
 	void *handle;
 	void *customdata;
 	StructRNA *srna;
-	const char *cb_regiontype_str;
-	int cb_regiontype;
 
 	if (PyTuple_GET_SIZE(args) < 2) {
 		PyErr_SetString(PyExc_ValueError, "callback_remove(handler): expected at least 2 args");
@@ -381,8 +379,9 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
 	}
 
 	if (srna == &RNA_WindowManager) {
-		if (!PyArg_ParseTuple(args, "OO!:WindowManager.draw_cursor_remove",
-		                      &cls, &PyCapsule_Type, &py_handle))
+		if (!PyArg_ParseTuple(
+		            args, "OO!:WindowManager.draw_cursor_remove",
+		            &cls, &PyCapsule_Type, &py_handle))
 		{
 			return NULL;
 		}
@@ -396,9 +395,17 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
 		Py_DECREF((PyObject *)customdata);
 	}
 	else if (RNA_struct_is_a(srna, &RNA_Space)) {
-		if (!PyArg_ParseTuple(args, "OO!s:Space.draw_handler_remove",
-		                      &cls, &PyCapsule_Type, &py_handle,  /* already assigned, no matter */
-		                      &cb_regiontype_str))
+		const char *error_prefix = "Space.draw_handler_remove";
+		struct {
+			const char *region_type_str;
+
+			int region_type;
+		} params;
+
+		if (!PyArg_ParseTuple(
+		            args, "OO!s:Space.draw_handler_remove",
+		            &cls, &PyCapsule_Type, &py_handle,  /* already assigned, no matter */
+		            &params.region_type_str))
 		{
 			return NULL;
 		}
@@ -407,8 +414,8 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
 		Py_DECREF((PyObject *)customdata);
 
 		if (pyrna_enum_value_from_id(
-		            rna_enum_region_type_items, cb_regiontype_str,
-		            &cb_regiontype, "bpy_struct.callback_remove()") == -1)
+		            rna_enum_region_type_items, params.region_type_str,
+		            &params.region_type, error_prefix) == -1)
 		{
 			return NULL;
 		}
@@ -420,9 +427,9 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
 			}
 			else {
 				SpaceType *st = BKE_spacetype_from_id(spaceid);
-				ARegionType *art = BKE_regiontype_from_id(st, cb_regiontype);
+				ARegionType *art = BKE_regiontype_from_id(st, params.region_type);
 				if (art == NULL) {
-					PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", cb_regiontype_str);
+					PyErr_Format(PyExc_TypeError, "region type '%.200s' not in space", params.region_type_str);
 					return NULL;
 				}
 				ED_region_draw_cb_exit(art, handle);



More information about the Bf-blender-cvs mailing list