[Bf-blender-cvs] [599a7ddf178] master: Cleanup: Move five interface files to C++

Hans Goudey noreply at git.blender.org
Sat Jul 30 06:24:01 CEST 2022


Commit: 599a7ddf1784882ae796d94f148aa2a830639bc0
Author: Hans Goudey
Date:   Fri Jul 29 23:16:58 2022 -0500
Branches: master
https://developer.blender.org/rB599a7ddf1784882ae796d94f148aa2a830639bc0

Cleanup: Move five interface files to C++

Builds on all four platforms on the buildbot. Includes clang tidy fixes.

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

M	source/blender/blenkernel/intern/workspace.c
M	source/blender/blenlib/BLI_listbase.h
M	source/blender/editors/interface/CMakeLists.txt
R085	source/blender/editors/interface/interface_anim.c	source/blender/editors/interface/interface_anim.cc
M	source/blender/editors/interface/interface_intern.h
R090	source/blender/editors/interface/interface_ops.c	source/blender/editors/interface/interface_ops.cc
R090	source/blender/editors/interface/interface_panel.c	source/blender/editors/interface/interface_panel.cc
R081	source/blender/editors/interface/interface_template_search_operator.c	source/blender/editors/interface/interface_template_search_operator.cc
R081	source/blender/editors/interface/interface_undo.c	source/blender/editors/interface/interface_undo.cc
M	source/blender/editors/sculpt_paint/paint_image_proj.c

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

diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 0265dd037b1..88e7db1fe6c 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -456,12 +456,12 @@ WorkSpaceLayout *BKE_workspace_layout_iter_circular(const WorkSpace *workspace,
   WorkSpaceLayout *iter_layout;
 
   if (iter_backward) {
-    LISTBASE_CIRCULAR_BACKWARD_BEGIN (&workspace->layouts, iter_layout, start) {
+    LISTBASE_CIRCULAR_BACKWARD_BEGIN (WorkSpaceLayout *, &workspace->layouts, iter_layout, start) {
       if (!callback(iter_layout, arg)) {
         return iter_layout;
       }
     }
-    LISTBASE_CIRCULAR_BACKWARD_END(&workspace->layouts, iter_layout, start);
+    LISTBASE_CIRCULAR_BACKWARD_END(WorkSpaceLayout *, &workspace->layouts, iter_layout, start);
   }
   else {
     LISTBASE_CIRCULAR_FORWARD_BEGIN (&workspace->layouts, iter_layout, start) {
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index 237fcdae8b9..9322fa4c85b 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -320,13 +320,13 @@ struct LinkData *BLI_genericNodeN(void *data);
   } \
   ((void)0)
 
-#define LISTBASE_CIRCULAR_BACKWARD_BEGIN(lb, lb_iter, lb_init) \
-  if ((lb)->last && (lb_init || (lb_init = (lb)->last))) { \
+#define LISTBASE_CIRCULAR_BACKWARD_BEGIN(type, lb, lb_iter, lb_init) \
+  if ((lb)->last && (lb_init || (lb_init = (type)(lb)->last))) { \
     lb_iter = lb_init; \
     do {
-#define LISTBASE_CIRCULAR_BACKWARD_END(lb, lb_iter, lb_init) \
+#define LISTBASE_CIRCULAR_BACKWARD_END(type, lb, lb_iter, lb_init) \
   } \
-  while ((lb_iter = (lb_iter)->prev ? (lb_iter)->prev : (lb)->last), (lb_iter != lb_init)) \
+  while ((lb_iter = (lb_iter)->prev ? (lb_iter)->prev : (type)(lb)->last), (lb_iter != lb_init)) \
     ; \
   } \
   ((void)0)
diff --git a/source/blender/editors/interface/CMakeLists.txt b/source/blender/editors/interface/CMakeLists.txt
index 08d1d3d9c61..56a639920a7 100644
--- a/source/blender/editors/interface/CMakeLists.txt
+++ b/source/blender/editors/interface/CMakeLists.txt
@@ -36,7 +36,7 @@ set(SRC
   eyedroppers/eyedropper_gpencil_color.c
   interface.cc
   interface_align.c
-  interface_anim.c
+  interface_anim.cc
   interface_button_group.c
   interface_context_menu.c
   interface_context_path.cc
@@ -47,8 +47,8 @@ set(SRC
   interface_icons.c
   interface_icons_event.c
   interface_layout.c
-  interface_ops.c
-  interface_panel.c
+  interface_ops.cc
+  interface_panel.cc
   interface_query.cc
   interface_region_color_picker.cc
   interface_region_hud.cc
@@ -64,9 +64,9 @@ set(SRC
   interface_template_attribute_search.cc
   interface_template_list.cc
   interface_template_search_menu.cc
-  interface_template_search_operator.c
+  interface_template_search_operator.cc
   interface_templates.c
-  interface_undo.c
+  interface_undo.cc
   interface_utils.cc
   interface_widgets.c
   resources.c
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.cc
similarity index 85%
rename from source/blender/editors/interface/interface_anim.c
rename to source/blender/editors/interface/interface_anim.cc
index d7d1d3ce260..8e898b7fe66 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.cc
@@ -4,9 +4,9 @@
  * \ingroup edinterface
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 #include "MEM_guardedalloc.h"
 
@@ -49,8 +49,14 @@ static FCurve *ui_but_get_fcurve(
    * but works well enough in typical cases */
   const int rnaindex = (but->rnaindex == -1) ? 0 : but->rnaindex;
 
-  return BKE_fcurve_find_by_rna_context_ui(
-      but->block->evil_C, &but->rnapoin, but->rnaprop, rnaindex, adt, action, r_driven, r_special);
+  return BKE_fcurve_find_by_rna_context_ui(static_cast<bContext *>(but->block->evil_C),
+                                           &but->rnapoin,
+                                           but->rnaprop,
+                                           rnaindex,
+                                           adt,
+                                           action,
+                                           r_driven,
+                                           r_special);
 }
 
 void ui_but_anim_flag(uiBut *but, const AnimationEvalContext *anim_eval_context)
@@ -93,7 +99,7 @@ void ui_but_anim_flag(uiBut *but, const AnimationEvalContext *anim_eval_context)
       }
 
       /* XXX: this feature is totally broken and useless with NLA */
-      if (adt == NULL || adt->nla_tracks.first == NULL) {
+      if (adt == nullptr || adt->nla_tracks.first == nullptr) {
         const AnimationEvalContext remapped_context = BKE_animsys_eval_context_construct_at(
             anim_eval_context, cfra);
         if (fcurve_is_changed(but->rnapoin, but->rnaprop, fcu, &remapped_context)) {
@@ -109,13 +115,13 @@ void ui_but_anim_flag(uiBut *but, const AnimationEvalContext *anim_eval_context)
 
 static uiBut *ui_but_anim_decorate_find_attached_button(uiButDecorator *but_decorate)
 {
-  uiBut *but_iter = NULL;
+  uiBut *but_iter = nullptr;
 
   BLI_assert(UI_but_is_decorator(&but_decorate->but));
   BLI_assert(but_decorate->rnapoin.data && but_decorate->rnaprop);
 
   LISTBASE_CIRCULAR_BACKWARD_BEGIN (
-      &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev) {
+      uiBut *, &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev) {
     if (but_iter != (uiBut *)but_decorate &&
         ui_but_rna_equals_ex(
             but_iter, &but_decorate->rnapoin, but_decorate->rnaprop, but_decorate->rnaindex)) {
@@ -123,9 +129,9 @@ static uiBut *ui_but_anim_decorate_find_attached_button(uiButDecorator *but_deco
     }
   }
   LISTBASE_CIRCULAR_BACKWARD_END(
-      &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev);
+      uiBut *, &but_decorate->but.block->buttons, but_iter, but_decorate->but.prev);
 
-  return NULL;
+  return nullptr;
 }
 
 void ui_but_anim_decorate_update_from_flag(uiButDecorator *decorator_but)
@@ -173,7 +179,7 @@ bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
   ChannelDriver *driver;
   bool driven, special;
 
-  fcu = ui_but_get_fcurve(but, NULL, NULL, &driven, &special);
+  fcu = ui_but_get_fcurve(but, nullptr, nullptr, &driven, &special);
 
   if (fcu && driven) {
     driver = fcu->driver;
@@ -195,13 +201,13 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
   ChannelDriver *driver;
   bool driven, special;
 
-  fcu = ui_but_get_fcurve(but, NULL, NULL, &driven, &special);
+  fcu = ui_but_get_fcurve(but, nullptr, nullptr, &driven, &special);
 
   if (fcu && driven) {
     driver = fcu->driver;
 
     if (driver && (driver->type == DRIVER_TYPE_PYTHON)) {
-      bContext *C = but->block->evil_C;
+      bContext *C = static_cast<bContext *>(but->block->evil_C);
 
       BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
 
@@ -213,7 +219,7 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
       fcu->flag &= ~FCURVE_DISABLED;
 
       /* this notifier should update the Graph Editor and trigger depsgraph refresh? */
-      WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, NULL);
+      WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, nullptr);
 
       DEG_relations_tag_update(CTX_data_main(C));
 
@@ -226,14 +232,14 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str)
 
 bool ui_but_anim_expression_create(uiBut *but, const char *str)
 {
-  bContext *C = but->block->evil_C;
+  bContext *C = static_cast<bContext *>(but->block->evil_C);
   ID *id;
   FCurve *fcu;
   char *path;
   bool ok = false;
 
   /* button must have RNA-pointer to a numeric-capable property */
-  if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
+  if (ELEM(nullptr, but->rnapoin.data, but->rnaprop)) {
     if (G.debug & G_DEBUG) {
       printf("ERROR: create expression failed - button has no RNA info attached\n");
     }
@@ -253,7 +259,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
   /* FIXME: until materials can be handled by depsgraph,
    * don't allow drivers to be created for them */
   id = but->rnapoin.owner_id;
-  if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
+  if ((id == nullptr) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
     if (G.debug & G_DEBUG) {
       printf("ERROR: create expression failed - invalid data-block for adding drivers (%p)\n", id);
     }
@@ -262,7 +268,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
 
   /* get path */
   path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
-  if (path == NULL) {
+  if (path == nullptr) {
     return false;
   }
 
@@ -282,7 +288,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str)
       /* updates */
       BKE_driver_invalidate_expression(driver, true, false);
       DEG_relations_tag_update(CTX_data_main(C));
-      WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, NULL);
+      WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, nullptr);
       ok = true;
     }
   }
@@ -300,19 +306,19 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
 void ui_but_anim_copy_driver(bContext *C)
 {
   /* this operator calls UI_context_active_but_prop_get */
-  WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, NULL, NULL);
+  WM_operator_name_call(C, "ANIM_OT_copy_driver_button", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
 }
 
 void ui_but_anim_paste_driver(bContext *C)
 {
   /* this operator calls UI_context_active_but_prop_get */
-  WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, NULL, NULL);
+  WM_operator_name_call(C, "ANIM_OT_paste_driver_button", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
 }
 
 void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void *UNUSED(arg_dummy))
 {
   wmWindowManager *wm = CTX_wm_manager(C);
-  uiButDecorator *but_decorate = arg_but;
+  uiButDecorator *but_decorate = static_cast<uiButDecorator *>(arg_but

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list