[Bf-blender-cvs] [862de9187f1] master: Cleanup: Move versioning_300.c to C++

Hans Goudey noreply at git.blender.org
Mon Sep 19 18:06:47 CEST 2022


Commit: 862de9187f1b914358c33dd9700e338f0174bbf0
Author: Hans Goudey
Date:   Mon Sep 19 11:06:21 2022 -0500
Branches: master
https://developer.blender.org/rB862de9187f1b914358c33dd9700e338f0174bbf0

Cleanup: Move versioning_300.c to C++

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

M	source/blender/blenloader/CMakeLists.txt
R092	source/blender/blenloader/intern/versioning_300.c	source/blender/blenloader/intern/versioning_300.cc

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

diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt
index bf99ca2cd9a..f0209d1337c 100644
--- a/source/blender/blenloader/CMakeLists.txt
+++ b/source/blender/blenloader/CMakeLists.txt
@@ -43,7 +43,7 @@ set(SRC
   intern/versioning_270.c
   intern/versioning_280.c
   intern/versioning_290.c
-  intern/versioning_300.c
+  intern/versioning_300.cc
   intern/versioning_400.cc
   intern/versioning_common.cc
   intern/versioning_cycles.c
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.cc
similarity index 92%
rename from source/blender/blenloader/intern/versioning_300.c
rename to source/blender/blenloader/intern/versioning_300.cc
index 244f74cfe59..e789cd66632 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.cc
@@ -6,7 +6,7 @@
 /* allow readfile to use deprecated functionality */
 #define DNA_DEPRECATED_ALLOW
 
-#include <string.h>
+#include <cstring>
 
 #include "CLG_log.h"
 
@@ -86,39 +86,40 @@ static IDProperty *idproperty_find_ui_container(IDProperty *idprop_group)
       return prop;
     }
   }
-  return NULL;
+  return nullptr;
 }
 
 static void version_idproperty_move_data_int(IDPropertyUIDataInt *ui_data,
                                              const IDProperty *prop_ui_data)
 {
   IDProperty *min = IDP_GetPropertyFromGroup(prop_ui_data, "min");
-  if (min != NULL) {
+  if (min != nullptr) {
     ui_data->min = ui_data->soft_min = IDP_coerce_to_int_or_zero(min);
   }
   IDProperty *max = IDP_GetPropertyFromGroup(prop_ui_data, "max");
-  if (max != NULL) {
+  if (max != nullptr) {
     ui_data->max = ui_data->soft_max = IDP_coerce_to_int_or_zero(max);
   }
   IDProperty *soft_min = IDP_GetPropertyFromGroup(prop_ui_data, "soft_min");
-  if (soft_min != NULL) {
+  if (soft_min != nullptr) {
     ui_data->soft_min = IDP_coerce_to_int_or_zero(soft_min);
     ui_data->soft_min = MIN2(ui_data->soft_min, ui_data->min);
   }
   IDProperty *soft_max = IDP_GetPropertyFromGroup(prop_ui_data, "soft_max");
-  if (soft_max != NULL) {
+  if (soft_max != nullptr) {
     ui_data->soft_max = IDP_coerce_to_int_or_zero(soft_max);
     ui_data->soft_max = MAX2(ui_data->soft_max, ui_data->max);
   }
   IDProperty *step = IDP_GetPropertyFromGroup(prop_ui_data, "step");
-  if (step != NULL) {
+  if (step != nullptr) {
     ui_data->step = IDP_coerce_to_int_or_zero(soft_max);
   }
   IDProperty *default_value = IDP_GetPropertyFromGroup(prop_ui_data, "default");
-  if (default_value != NULL) {
+  if (default_value != nullptr) {
     if (default_value->type == IDP_ARRAY) {
       if (default_value->subtype == IDP_INT) {
-        ui_data->default_array = MEM_malloc_arrayN(default_value->len, sizeof(int), __func__);
+        ui_data->default_array = static_cast<int *>(
+            MEM_malloc_arrayN(default_value->len, sizeof(int), __func__));
         memcpy(ui_data->default_array, IDP_Array(default_value), sizeof(int) * default_value->len);
         ui_data->default_array_len = default_value->len;
       }
@@ -133,45 +134,47 @@ static void version_idproperty_move_data_float(IDPropertyUIDataFloat *ui_data,
                                                const IDProperty *prop_ui_data)
 {
   IDProperty *min = IDP_GetPropertyFromGroup(prop_ui_data, "min");
-  if (min != NULL) {
+  if (min != nullptr) {
     ui_data->min = ui_data->soft_min = IDP_coerce_to_double_or_zero(min);
   }
   IDProperty *max = IDP_GetPropertyFromGroup(prop_ui_data, "max");
-  if (max != NULL) {
+  if (max != nullptr) {
     ui_data->max = ui_data->soft_max = IDP_coerce_to_double_or_zero(max);
   }
   IDProperty *soft_min = IDP_GetPropertyFromGroup(prop_ui_data, "soft_min");
-  if (soft_min != NULL) {
+  if (soft_min != nullptr) {
     ui_data->soft_min = IDP_coerce_to_double_or_zero(soft_min);
     ui_data->soft_min = MAX2(ui_data->soft_min, ui_data->min);
   }
   IDProperty *soft_max = IDP_GetPropertyFromGroup(prop_ui_data, "soft_max");
-  if (soft_max != NULL) {
+  if (soft_max != nullptr) {
     ui_data->soft_max = IDP_coerce_to_double_or_zero(soft_max);
     ui_data->soft_max = MIN2(ui_data->soft_max, ui_data->max);
   }
   IDProperty *step = IDP_GetPropertyFromGroup(prop_ui_data, "step");
-  if (step != NULL) {
+  if (step != nullptr) {
     ui_data->step = IDP_coerce_to_float_or_zero(step);
   }
   IDProperty *precision = IDP_GetPropertyFromGroup(prop_ui_data, "precision");
-  if (precision != NULL) {
+  if (precision != nullptr) {
     ui_data->precision = IDP_coerce_to_int_or_zero(precision);
   }
   IDProperty *default_value = IDP_GetPropertyFromGroup(prop_ui_data, "default");
-  if (default_value != NULL) {
+  if (default_value != nullptr) {
     if (default_value->type == IDP_ARRAY) {
       const int array_len = default_value->len;
       ui_data->default_array_len = array_len;
       if (default_value->subtype == IDP_FLOAT) {
-        ui_data->default_array = MEM_malloc_arrayN(array_len, sizeof(double), __func__);
-        const float *old_default_array = IDP_Array(default_value);
+        ui_data->default_array = static_cast<double *>(
+            MEM_malloc_arrayN(array_len, sizeof(double), __func__));
+        const float *old_default_array = static_cast<const float *>(IDP_Array(default_value));
         for (int i = 0; i < ui_data->default_array_len; i++) {
           ui_data->default_array[i] = (double)old_default_array[i];
         }
       }
       else if (default_value->subtype == IDP_DOUBLE) {
-        ui_data->default_array = MEM_malloc_arrayN(array_len, sizeof(double), __func__);
+        ui_data->default_array = static_cast<double *>(
+            MEM_malloc_arrayN(array_len, sizeof(double), __func__));
         memcpy(ui_data->default_array, IDP_Array(default_value), sizeof(double) * array_len);
       }
     }
@@ -185,25 +188,26 @@ static void version_idproperty_move_data_string(IDPropertyUIDataString *ui_data,
                                                 const IDProperty *prop_ui_data)
 {
   IDProperty *default_value = IDP_GetPropertyFromGroup(prop_ui_data, "default");
-  if (default_value != NULL && default_value->type == IDP_STRING) {
+  if (default_value != nullptr && default_value->type == IDP_STRING) {
     ui_data->default_value = BLI_strdup(IDP_String(default_value));
   }
 }
 
 static void version_idproperty_ui_data(IDProperty *idprop_group)
 {
-  if (idprop_group == NULL) { /* NULL check here to reduce verbosity of calls to this function. */
+  if (idprop_group ==
+      nullptr) { /* nullptr check here to reduce verbosity of calls to this function. */
     return;
   }
 
   IDProperty *ui_container = idproperty_find_ui_container(idprop_group);
-  if (ui_container == NULL) {
+  if (ui_container == nullptr) {
     return;
   }
 
   LISTBASE_FOREACH (IDProperty *, prop, &idprop_group->data.group) {
     IDProperty *prop_ui_data = IDP_GetPropertyFromGroup(ui_container, prop->name);
-    if (prop_ui_data == NULL) {
+    if (prop_ui_data == nullptr) {
       continue;
     }
 
@@ -214,7 +218,7 @@ static void version_idproperty_ui_data(IDProperty *idprop_group)
     IDPropertyUIData *ui_data = IDP_ui_data_ensure(prop);
 
     IDProperty *subtype = IDP_GetPropertyFromGroup(prop_ui_data, "subtype");
-    if (subtype != NULL && subtype->type == IDP_STRING) {
+    if (subtype != nullptr && subtype->type == IDP_STRING) {
       const char *subtype_string = IDP_String(subtype);
       int result = PROP_NONE;
       RNA_enum_value_from_id(rna_enum_property_subtype_items, subtype_string, &result);
@@ -222,7 +226,7 @@ static void version_idproperty_ui_data(IDProperty *idprop_group)
     }
 
     IDProperty *description = IDP_GetPropertyFromGroup(prop_ui_data, "description");
-    if (description != NULL && description->type == IDP_STRING) {
+    if (description != nullptr && description->type == IDP_STRING) {
       ui_data->description = BLI_strdup(IDP_String(description));
     }
 
@@ -318,7 +322,7 @@ static void do_versions_idproperty_ui_data(Main *bmain)
     }
 
     /* Object post bones. */
-    if (ob->type == OB_ARMATURE && ob->pose != NULL) {
+    if (ob->type == OB_ARMATURE && ob->pose != nullptr) {
       LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
         version_idproperty_ui_data(pchan->prop);
       }
@@ -327,7 +331,7 @@ static void do_versions_idproperty_ui_data(Main *bmain)
 
   /* Sequences. */
   LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
-    if (scene->ed != NULL) {
+    if (scene->ed != nullptr) {
       do_versions_idproperty_seq_recursive(&scene->ed->seqbase);
     }
   }
@@ -343,7 +347,7 @@ static void sort_linked_ids(Main *bmain)
       if (ID_IS_LINKED(id)) {
         BLI_remlink(lb, id);
         BLI_addtail(&temp_list, id);
-        id_sort_by_name(&temp_list, id, NULL);
+        id_sort_by_name(&temp_list, id, nullptr);
       }
     }
     BLI_movelisttolist(lb, &temp_list);
@@ -356,9 +360,9 @@ static void assert_sorted_ids(Main *bmain)
 #ifndef NDEBUG
   ListBase *lb;
   FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb) {
-    ID *id_prev = NULL;
+    ID *id_prev = nullptr;
     LISTBASE_FOREACH (ID *, id, lb) {
-      if (id_prev == NULL) {
+      if (id_prev == nullptr) {
         continue;
       }
       BLI_assert(id_prev->lib != id->lib || BLI_strcasecmp(id_prev->name, id->name) < 0);
@@ -399,7 +403,7 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     if (seq->type == SEQ_TYPE_SPEED) {
       SpeedControlVars *v = (SpeedControlVars *)seq->effectdata;
-      const char *substr = NULL;
+      const char *substr = nullptr;
       float globalSpeed = v->globalSpeed;
       if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) {
         if (globalSpeed == 1.0f) {
@@ -433,7 +437,8 @@ static void do_versions_sequencer_speed_effect_recursive(Scene *scene, const Lis
       v->flags &= ~(SEQ_SPEED_INTEGRATE | SEQ_SPEED_COMPRESS_IPO_Y);
 
       if (substr || globalSpeed != 1.0f) {
-        FCurve *fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL);
+        FCurve *fcu = id_data_find_fcurve(
+            &scene->id, seq, &RNA_Sequence,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list