[Bf-blender-cvs] [83c274ccfc8] master: Cleanup: use "num" as a suffix in: source/blender/python

Campbell Barton noreply at git.blender.org
Mon Mar 28 05:42:13 CEST 2022


Commit: 83c274ccfc86c168657af9de9939cd96b0fc3f41
Author: Campbell Barton
Date:   Mon Mar 28 11:06:01 2022 +1100
Branches: master
https://developer.blender.org/rB83c274ccfc86c168657af9de9939cd96b0fc3f41

Cleanup: use "num" as a suffix in: source/blender/python

See T85728

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

M	source/blender/freestyle/intern/python/BPy_Convert.cpp
M	source/blender/python/bmesh/bmesh_py_ops_call.c
M	source/blender/python/bmesh/bmesh_py_types.c
M	source/blender/python/gpu/gpu_py_shader.c
M	source/blender/python/intern/bpy_app_handlers.c
M	source/blender/python/intern/bpy_rna_array.c
M	source/blender/python/mathutils/mathutils.c
M	source/blender/python/mathutils/mathutils.h
M	source/blender/python/mathutils/mathutils_Matrix.c
M	source/blender/python/mathutils/mathutils_Matrix.h
M	source/blender/python/mathutils/mathutils_Quaternion.c
M	source/blender/python/mathutils/mathutils_Vector.c
M	source/blender/python/mathutils/mathutils_Vector.h
M	source/blender/python/mathutils/mathutils_geometry.c
M	source/blender/python/mathutils/mathutils_noise.c

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

diff --git a/source/blender/freestyle/intern/python/BPy_Convert.cpp b/source/blender/freestyle/intern/python/BPy_Convert.cpp
index 55a33720465..02ed3f463c7 100644
--- a/source/blender/freestyle/intern/python/BPy_Convert.cpp
+++ b/source/blender/freestyle/intern/python/BPy_Convert.cpp
@@ -569,7 +569,7 @@ bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r &vec)
 
 bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f &vec)
 {
-  if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2) {
+  if (!VectorObject_Check(obj) || ((VectorObject *)obj)->vec_num != 2) {
     return false;
   }
   if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
@@ -582,7 +582,7 @@ bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f &vec)
 
 bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f &vec)
 {
-  if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) {
+  if (!VectorObject_Check(obj) || ((VectorObject *)obj)->vec_num != 3) {
     return false;
   }
   if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
@@ -596,7 +596,7 @@ bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f &vec)
 
 bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r &vec)
 {
-  if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) {
+  if (!VectorObject_Check(obj) || ((VectorObject *)obj)->vec_num != 3) {
     return false;
   }
   if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
@@ -758,7 +758,7 @@ bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r &vec)
 
 bool float_array_from_PyObject(PyObject *obj, float *v, int n)
 {
-  if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) {
+  if (VectorObject_Check(obj) && ((VectorObject *)obj)->vec_num == n) {
     if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
       return false;
     }
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index 6492f528a5e..35d5cb6a994 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -233,8 +233,8 @@ static int bpy_slot_from_py(BMesh *bm,
       if (!Matrix_ParseAny(value, &pymat)) {
         return -1;
       }
-      const ushort size = pymat->num_col;
-      if ((size != pymat->num_row) || (!ELEM(size, 3, 4))) {
+      const ushort size = pymat->col_num;
+      if ((size != pymat->row_num) || (!ELEM(size, 3, 4))) {
         PyErr_Format(PyExc_TypeError,
                      "%.200s: keyword \"%.200s\" expected a 3x3 or 4x4 matrix",
                      opname,
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 9ceff9b84b6..46f89dd4103 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -1309,7 +1309,7 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
   if (BaseMath_ReadCallback(mat) == -1) {
     return NULL;
   }
-  if (mat->num_col != 4 || mat->num_row != 4) {
+  if (mat->col_num != 4 || mat->row_num != 4) {
     PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
     return NULL;
   }
diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c
index 1a53ccd6686..43b26e05327 100644
--- a/source/blender/python/gpu/gpu_py_shader.c
+++ b/source/blender/python/gpu/gpu_py_shader.c
@@ -381,11 +381,11 @@ static PyObject *pygpu_shader_uniform_float(BPyGPUShader *self, PyObject *args)
     if (BaseMath_ReadCallback(mat) == -1) {
       return NULL;
     }
-    if ((mat->num_row != mat->num_col) || !ELEM(mat->num_row, 3, 4)) {
+    if ((mat->row_num != mat->col_num) || !ELEM(mat->row_num, 3, 4)) {
       PyErr_SetString(PyExc_ValueError, "Expected 3x3 or 4x4 matrix");
       return NULL;
     }
-    length = mat->num_row * mat->num_col;
+    length = mat->row_num * mat->col_num;
     memcpy(values, mat->matrix, sizeof(float) * length);
   }
   else {
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index ba3e6a3d74b..34ffef03e66 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -24,7 +24,7 @@
 
 void bpy_app_generic_callback(struct Main *main,
                               struct PointerRNA **pointers,
-                              const int num_pointers,
+                              const int pointers_num,
                               void *arg);
 
 static PyTypeObject BlenderAppCbType;
@@ -305,7 +305,7 @@ static PyObject *choose_arguments(PyObject *func, PyObject *args_all, PyObject *
 /* the actual callback - not necessarily called from py */
 void bpy_app_generic_callback(struct Main *UNUSED(main),
                               struct PointerRNA **pointers,
-                              const int num_pointers,
+                              const int pointers_num,
                               void *arg)
 {
   PyObject *cb_list = py_cb_array[POINTER_AS_INT(arg)];
@@ -320,14 +320,14 @@ void bpy_app_generic_callback(struct Main *UNUSED(main),
     Py_ssize_t pos;
 
     /* setup arguments */
-    for (int i = 0; i < num_pointers; ++i) {
+    for (int i = 0; i < pointers_num; ++i) {
       PyTuple_SET_ITEM(args_all, i, pyrna_struct_CreatePyObject(pointers[i]));
     }
-    for (int i = num_pointers; i < num_arguments; ++i) {
+    for (int i = pointers_num; i < num_arguments; ++i) {
       PyTuple_SET_ITEM(args_all, i, Py_INCREF_RET(Py_None));
     }
 
-    if (num_pointers == 0) {
+    if (pointers_num == 0) {
       PyTuple_SET_ITEM(args_single, 0, Py_INCREF_RET(Py_None));
     }
     else {
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c
index f5bec247250..8506ec97bc3 100644
--- a/source/blender/python/intern/bpy_rna_array.c
+++ b/source/blender/python/intern/bpy_rna_array.c
@@ -377,15 +377,15 @@ static int validate_array(PyObject *rvalue,
                      totdim);
         return -1;
       }
-      if (pymat->num_col != dimsize[0] || pymat->num_row != dimsize[1]) {
+      if (pymat->col_num != dimsize[0] || pymat->row_num != dimsize[1]) {
         PyErr_Format(PyExc_ValueError,
                      "%s %.200s.%.200s, matrix assign dimension size mismatch, "
                      "is %dx%d, expected be %dx%d",
                      error_prefix,
                      RNA_struct_identifier(ptr->type),
                      RNA_property_identifier(prop),
-                     pymat->num_col,
-                     pymat->num_row,
+                     pymat->col_num,
+                     pymat->row_num,
                      dimsize[0],
                      dimsize[1]);
         return -1;
@@ -473,7 +473,7 @@ static char *copy_values(PyObject *seq,
   if (dim == 0) {
     if (MatrixObject_Check(seq)) {
       MatrixObject *pymat = (MatrixObject *)seq;
-      const size_t allocsize = pymat->num_col * pymat->num_row * sizeof(float);
+      const size_t allocsize = pymat->col_num * pymat->row_num * sizeof(float);
 
       /* read callback already done by validate */
       /* since this is the first iteration we can assume data is allocated */
diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c
index 8ed156a7e55..1aa2cec861c 100644
--- a/source/blender/python/mathutils/mathutils.c
+++ b/source/blender/python/mathutils/mathutils.c
@@ -92,47 +92,46 @@ Py_hash_t mathutils_array_hash(const float *array, size_t array_len)
 }
 
 int mathutils_array_parse(
-    float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
+    float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
 {
-  const uint flag = array_max;
-  int size;
+  const uint flag = array_num_max;
+  int num;
 
-  array_max &= ~MU_ARRAY_FLAGS;
+  array_num_max &= ~MU_ARRAY_FLAGS;
 
 #if 1 /* approx 6x speedup for mathutils types */
 
-  if ((size = VectorObject_Check(value) ? ((VectorObject *)value)->size : 0) ||
-      (size = EulerObject_Check(value) ? 3 : 0) ||
-      (size = QuaternionObject_Check(value) ? 4 : 0) ||
-      (size = ColorObject_Check(value) ? 3 : 0)) {
+  if ((num = VectorObject_Check(value) ? ((VectorObject *)value)->vec_num : 0) ||
+      (num = EulerObject_Check(value) ? 3 : 0) || (num = QuaternionObject_Check(value) ? 4 : 0) ||
+      (num = ColorObject_Check(value) ? 3 : 0)) {
     if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
       return -1;
     }
 
     if (flag & MU_ARRAY_SPILL) {
-      CLAMP_MAX(size, array_max);
+      CLAMP_MAX(num, array_num_max);
     }
 
-    if (size > array_max || size < array_min) {
-      if (array_max == array_min) {
+    if (num > array_num_max || num < array_num_min) {
+      if (array_num_max == array_num_min) {
         PyErr_Format(PyExc_ValueError,
-                     "%.200s: sequence size is %d, expected %d",
+                     "%.200s: sequence length is %d, expected %d",
                      error_prefix,
-                     size,
-                     array_max);
+                     num,
+                     array_num_max);
       }
       else {
         PyErr_Format(PyExc_ValueError,
-                     "%.200s: sequence size is %d, expected [%d - %d]",
+                     "%.200s: sequence length is %d, expected [%d - %d]",
                      error_prefix,
-                     size,
-                     array_min,
-                     array_max);
+                     num,
+                     array_num_min,
+                     array_num_max);
       }
       return -1;
     }
 
-    memcpy(array, ((const BaseMathObject *)value)->data, size * sizeof(float));
+    memcpy(array, ((const BaseMathObject *)value)->data, num * sizeof(float));
   }
   else
 #endif
@@ -145,77 +144,76 @@ int mathutils_array_parse(
       return -1;
     }
 
-    size = PySequence_Fast_GET_SIZE(value_fast);
+    num = PySequence_Fast_GET_SIZE(value_fast);
 
     if (flag & MU_ARRAY_SPILL) {
-      CLAMP_MAX(size, array_max);
+      CLAMP_MAX(num, array_num_max);
     }
 
-    if (size > array_max || size < array_min) {
-      if (array_max == array_min) {
+    if (num > array_num_max || num < array

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list