[Bf-blender-cvs] [228edcaedd9] master: Cleanup: bpy.props variable names

Campbell Barton noreply at git.blender.org
Fri Jul 30 08:17:17 CEST 2021


Commit: 228edcaedd9baf95e98c001bae455d80f782a34a
Author: Campbell Barton
Date:   Fri Jul 30 16:03:52 2021 +1000
Branches: master
https://developer.blender.org/rB228edcaedd9baf95e98c001bae455d80f782a34a

Cleanup: bpy.props variable names

- Use `default` instead of `def` abbreviation.
- Rename `BPYPropArrayLength` to `BPyPropArrayLength`
  in keeping with other local structs.
- Remove _PyArg_Parser.fname value accidentally left in
  (harmless as it's not used).

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

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

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

diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index 4b4ca5a0209..226d740c5e0 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -495,7 +495,7 @@ static void bpy_prop_assign_flag_override(PropertyRNA *prop, const int flag_over
 /** \name Multi-Dimensional Property Utilities
  * \{ */
 
-struct BPYPropArrayLength {
+struct BPyPropArrayLength {
   int len_total;
   /** Ignore `dims` when `dims_len == 0`. */
   int dims[RNA_MAX_ARRAY_DIMENSION];
@@ -507,7 +507,7 @@ struct BPYPropArrayLength {
  */
 static int bpy_prop_array_length_parse(PyObject *o, void *p)
 {
-  struct BPYPropArrayLength *array_len_info = p;
+  struct BPyPropArrayLength *array_len_info = p;
 
   if (PyLong_CheckExact(o)) {
     int size;
@@ -574,7 +574,7 @@ static int bpy_prop_array_length_parse(PyObject *o, void *p)
 static int bpy_prop_array_from_py_with_dims(void *values,
                                             size_t values_elem_size,
                                             PyObject *py_values,
-                                            const struct BPYPropArrayLength *array_len_info,
+                                            const struct BPyPropArrayLength *array_len_info,
                                             const PyTypeObject *type,
                                             const char *error_str)
 {
@@ -588,7 +588,7 @@ static int bpy_prop_array_from_py_with_dims(void *values,
 }
 
 static bool bpy_prop_array_is_matrix_compatible_ex(int subtype,
-                                                   const struct BPYPropArrayLength *array_len_info)
+                                                   const struct BPyPropArrayLength *array_len_info)
 {
   return ((subtype == PROP_MATRIX) && (array_len_info->dims_len == 2) &&
           ((array_len_info->dims[0] >= 2) && (array_len_info->dims[0] >= 4)) &&
@@ -596,7 +596,7 @@ static bool bpy_prop_array_is_matrix_compatible_ex(int subtype,
 }
 
 static bool bpy_prop_array_is_matrix_compatible(PropertyRNA *prop,
-                                                const struct BPYPropArrayLength *array_len_info)
+                                                const struct BPyPropArrayLength *array_len_info)
 {
   BLI_assert(RNA_property_type(prop) == PROP_FLOAT);
   return bpy_prop_array_is_matrix_compatible_ex(RNA_property_subtype(prop), array_len_info);
@@ -606,7 +606,7 @@ static bool bpy_prop_array_is_matrix_compatible(PropertyRNA *prop,
  * Needed since the internal storage of matrices swaps row/column.
  */
 static void bpy_prop_array_matrix_swap_row_column_vn_vn(
-    float *values_dst, const float *values_src, const struct BPYPropArrayLength *array_len_info)
+    float *values_dst, const float *values_src, const struct BPyPropArrayLength *array_len_info)
 {
   BLI_assert(values_dst != values_src);
   const int dim0 = array_len_info->dims[0], dim1 = array_len_info->dims[1];
@@ -619,7 +619,7 @@ static void bpy_prop_array_matrix_swap_row_column_vn_vn(
 }
 
 static void bpy_prop_array_matrix_swap_row_column_vn(
-    float *values, const struct BPYPropArrayLength *array_len_info)
+    float *values, const struct BPyPropArrayLength *array_len_info)
 {
   const int dim0 = array_len_info->dims[0], dim1 = array_len_info->dims[1];
   BLI_assert(dim0 <= 4 && dim1 <= 4);
@@ -828,7 +828,7 @@ static void bpy_prop_boolean_array_get_fn(struct PointerRNA *ptr,
   const bool is_write_ok = pyrna_write_check();
   bool is_values_set = false;
   int i, len = RNA_property_array_length(ptr, prop);
-  struct BPYPropArrayLength array_len_info = {.len_total = len};
+  struct BPyPropArrayLength array_len_info = {.len_total = len};
   array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
 
   BLI_assert(prop_store != NULL);
@@ -898,7 +898,7 @@ static void bpy_prop_boolean_array_set_fn(struct PointerRNA *ptr,
   bool use_gil;
   const bool is_write_ok = pyrna_write_check();
   const int len = RNA_property_array_length(ptr, prop);
-  struct BPYPropArrayLength array_len_info = {.len_total = len};
+  struct BPyPropArrayLength array_len_info = {.len_total = len};
   array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
 
   BLI_assert(prop_store != NULL);
@@ -1089,7 +1089,7 @@ static void bpy_prop_int_array_get_fn(struct PointerRNA *ptr,
   const bool is_write_ok = pyrna_write_check();
   bool is_values_set = false;
   int i, len = RNA_property_array_length(ptr, prop);
-  struct BPYPropArrayLength array_len_info = {.len_total = len};
+  struct BPyPropArrayLength array_len_info = {.len_total = len};
   array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
 
   BLI_assert(prop_store != NULL);
@@ -1159,7 +1159,7 @@ static void bpy_prop_int_array_set_fn(struct PointerRNA *ptr,
   bool use_gil;
   const bool is_write_ok = pyrna_write_check();
   const int len = RNA_property_array_length(ptr, prop);
-  struct BPYPropArrayLength array_len_info = {.len_total = len};
+  struct BPyPropArrayLength array_len_info = {.len_total = len};
   array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
 
   BLI_assert(prop_store != NULL);
@@ -1351,7 +1351,7 @@ static void bpy_prop_float_array_get_fn(struct PointerRNA *ptr,
   const bool is_write_ok = pyrna_write_check();
   bool is_values_set = false;
   int i, len = RNA_property_array_length(ptr, prop);
-  struct BPYPropArrayLength array_len_info = {.len_total = len};
+  struct BPyPropArrayLength array_len_info = {.len_total = len};
   array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
 
   BLI_assert(prop_store != NULL);
@@ -1425,7 +1425,7 @@ static void bpy_prop_float_array_set_fn(struct PointerRNA *ptr,
   bool use_gil;
   const bool is_write_ok = pyrna_write_check();
   const int len = RNA_property_array_length(ptr, prop);
-  struct BPYPropArrayLength array_len_info = {.len_total = len};
+  struct BPyPropArrayLength array_len_info = {.len_total = len};
   array_len_info.dims_len = RNA_property_array_dimension(ptr, prop, array_len_info.dims);
 
   BLI_assert(prop_store != NULL);
@@ -1898,9 +1898,9 @@ static int icon_id_from_name(const char *name)
 }
 
 static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
-                                                  PyObject *def,
-                                                  int *defvalue,
-                                                  const bool is_enum_flag)
+                                                  const bool is_enum_flag,
+                                                  PyObject *default_py,
+                                                  int *r_default_value)
 {
   EnumPropertyItem *items;
   PyObject *item;
@@ -1908,9 +1908,9 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
   PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
   Py_ssize_t totbuf = 0;
   int i;
-  short def_used = 0;
-  const char *def_string_cmp = NULL;
-  int def_int_cmp = 0;
+  short default_used = 0;
+  const char *default_str_cmp = NULL;
+  int default_int_cmp = 0;
 
   if (is_enum_flag) {
     if (seq_len > RNA_ENUM_BITFLAG_SIZE) {
@@ -1919,23 +1919,23 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
                           RNA_ENUM_BITFLAG_SIZE) " members for a ENUM_FLAG type property");
       return NULL;
     }
-    if (def && !PySet_Check(def)) {
+    if (default_py && !PySet_Check(default_py)) {
       PyErr_Format(PyExc_TypeError,
                    "EnumProperty(...): default option must be a 'set' "
                    "type when ENUM_FLAG is enabled, not a '%.200s'",
-                   Py_TYPE(def)->tp_name);
+                   Py_TYPE(default_py)->tp_name);
       return NULL;
     }
   }
   else {
-    if (def) {
-      if (!py_long_as_int(def, &def_int_cmp)) {
-        def_string_cmp = PyUnicode_AsUTF8(def);
-        if (def_string_cmp == NULL) {
+    if (default_py) {
+      if (!py_long_as_int(default_py, &default_int_cmp)) {
+        default_str_cmp = PyUnicode_AsUTF8(default_py);
+        if (default_str_cmp == NULL) {
           PyErr_Format(PyExc_TypeError,
                        "EnumProperty(...): default option must be a 'str' or 'int' "
                        "type when ENUM_FLAG is disabled, not a '%.200s'",
-                       Py_TYPE(def)->tp_name);
+                       Py_TYPE(default_py)->tp_name);
           return NULL;
         }
       }
@@ -1943,7 +1943,7 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
   }
 
   /* blank value */
-  *defvalue = 0;
+  *r_default_value = 0;
 
   items = MEM_callocN(sizeof(EnumPropertyItem) * (seq_len + 1), "enum_items_from_py1");
 
@@ -1972,9 +1972,9 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
           tmp.value = 1 << i;
         }
 
-        if (def && PySet_Contains(def, PyTuple_GET_ITEM(item, 0))) {
-          *defvalue |= tmp.value;
-          def_used++;
+        if (default_py && PySet_Contains(default_py, PyTuple_GET_ITEM(item, 0))) {
+          *r_default_value |= tmp.value;
+          default_used++;
         }
       }
       else {
@@ -1982,11 +1982,11 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
           tmp.value = i;
         }
 
-        if (def && def_used == 0) {
-          if ((def_string_cmp != NULL && STREQ(def_string_cmp, tmp.identifier)) ||
-              (def_string_cmp == NULL && def_int_cmp == tmp.value)) {
-            *defvalue = tmp.value;
-            def_used++; /* only ever 1 */
+        if (default_py && default_used == 0) {
+          if ((default_str_cmp != NULL && STREQ(default_str_cmp, tmp.identifier)) ||
+              (default_str_cmp == NULL && default_int_cmp == tmp.value)) {
+            *r_default_value = tmp.value;
+            default_used++; /* only ever 1 */
           }
         }
       }
@@ -2016,28 +2016,28 @@ static const EnumPropertyItem *enum_items_from_py(PyObject *seq_fast,
 
   if (is_enum_flag) {
     /* strict check that all set members were used */
-    if (def && def_used != PySet_GET_SIZE(def)) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list