[Bf-blender-cvs] [9cce18a5858] master: Info Editor: move to c++

Jacques Lucke noreply at git.blender.org
Sat Apr 24 17:00:47 CEST 2021


Commit: 9cce18a5858cb93da626f5f0fd7e09cd66637e05
Author: Jacques Lucke
Date:   Sat Apr 24 17:00:19 2021 +0200
Branches: master
https://developer.blender.org/rB9cce18a5858cb93da626f5f0fd7e09cd66637e05

Info Editor: move to c++

I'm currently doing some experiments in the info editor and
for that it is easier if the info editor is in c++ already.

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/editors/space_info/CMakeLists.txt
R088	source/blender/editors/space_info/info_draw.c	source/blender/editors/space_info/info_draw.cc
R100	source/blender/editors/space_info/info_intern.h	source/blender/editors/space_info/info_intern.hh
R093	source/blender/editors/space_info/info_ops.c	source/blender/editors/space_info/info_ops.cc
R090	source/blender/editors/space_info/info_report.c	source/blender/editors/space_info/info_report.cc
R091	source/blender/editors/space_info/info_stats.c	source/blender/editors/space_info/info_stats.cc
R092	source/blender/editors/space_info/space_info.c	source/blender/editors/space_info/space_info.cc
R095	source/blender/editors/space_info/textview.c	source/blender/editors/space_info/textview.cc
M	source/blender/editors/space_info/textview.h
M	source/blender/windowmanager/message_bus/wm_message_bus.h

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 240d6cb18ec..a89ece567a2 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -325,7 +325,7 @@ void BKE_view_layer_visible_bases_iterator_end(BLI_Iterator *iter);
   { \
     Object *_instance; \
     Base *_base; \
-    for (_base = (view_layer)->object_bases.first; _base; _base = _base->next) { \
+    for (_base = (Base *)(view_layer)->object_bases.first; _base; _base = _base->next) { \
       _instance = _base->object;
 
 #define FOREACH_OBJECT_END \
diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt
index b6df07eec4e..15194082376 100644
--- a/source/blender/editors/space_info/CMakeLists.txt
+++ b/source/blender/editors/space_info/CMakeLists.txt
@@ -34,14 +34,14 @@ set(INC
 )
 
 set(SRC
-  info_draw.c
-  info_ops.c
-  info_report.c
-  info_stats.c
-  space_info.c
-  textview.c
+  info_draw.cc
+  info_ops.cc
+  info_report.cc
+  info_stats.cc
+  space_info.cc
+  textview.cc
 
-  info_intern.h
+  info_intern.hh
   textview.h
 )
 
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.cc
similarity index 88%
rename from source/blender/editors/space_info/info_draw.c
rename to source/blender/editors/space_info/info_draw.cc
index be3b60d581b..852447372d6 100644
--- a/source/blender/editors/space_info/info_draw.c
+++ b/source/blender/editors/space_info/info_draw.cc
@@ -21,8 +21,8 @@
  * \ingroup spinfo
  */
 
-#include <limits.h>
-#include <string.h>
+#include <climits>
+#include <cstring>
 
 #include "BLI_utildefines.h"
 
@@ -35,7 +35,7 @@
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
-#include "info_intern.h"
+#include "info_intern.hh"
 #include "textview.h"
 
 static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
@@ -45,7 +45,7 @@ static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
                                                        uchar r_icon_fg[4],
                                                        uchar r_icon_bg[4])
 {
-  const Report *report = tvc->iter;
+  const Report *report = (const Report *)tvc->iter;
 
   /* Same text color no matter what type of report. */
   UI_GetThemeColor4ubv((report->flag & SELECT) ? TH_INFO_SELECTED_TEXT : TH_TEXT, fg);
@@ -71,16 +71,17 @@ static enum eTextViewContext_LineFlag report_line_data(TextViewContext *tvc,
     /* This theme color is RGB only, so set alpha. */
     r_icon_fg[3] = 255;
     UI_GetThemeColor4ubv(icon_bg_id, r_icon_bg);
-    return TVC_LINE_FG | TVC_LINE_BG | TVC_LINE_ICON | TVC_LINE_ICON_FG | TVC_LINE_ICON_BG;
+    return (enum eTextViewContext_LineFlag)(TVC_LINE_FG | TVC_LINE_BG | TVC_LINE_ICON |
+                                            TVC_LINE_ICON_FG | TVC_LINE_ICON_BG);
   }
 
-  return TVC_LINE_FG | TVC_LINE_BG;
+  return (enum eTextViewContext_LineFlag)(TVC_LINE_FG | TVC_LINE_BG);
 }
 
 /* reports! */
 static void report_textview_init__internal(TextViewContext *tvc)
 {
-  const Report *report = tvc->iter;
+  const Report *report = (const Report *)tvc->iter;
   const char *str = report->message;
   for (int i = tvc->iter_char_end - 1; i >= 0; i -= 1) {
     if (str[i] == '\n') {
@@ -93,17 +94,17 @@ static void report_textview_init__internal(TextViewContext *tvc)
 
 static int report_textview_skip__internal(TextViewContext *tvc)
 {
-  const SpaceInfo *sinfo = tvc->arg1;
+  const SpaceInfo *sinfo = (const SpaceInfo *)tvc->arg1;
   const int report_mask = info_report_mask(sinfo);
   while (tvc->iter && (((const Report *)tvc->iter)->type & report_mask) == 0) {
     tvc->iter = (void *)((Link *)tvc->iter)->prev;
   }
-  return (tvc->iter != NULL);
+  return (tvc->iter != nullptr);
 }
 
 static int report_textview_begin(TextViewContext *tvc)
 {
-  const ReportList *reports = tvc->arg2;
+  const ReportList *reports = (const ReportList *)tvc->arg2;
 
   tvc->sel_start = 0;
   tvc->sel_end = 0;
@@ -116,7 +117,7 @@ static int report_textview_begin(TextViewContext *tvc)
   tvc->iter_tmp = 0;
   if (tvc->iter && report_textview_skip__internal(tvc)) {
     /* init the newline iterator */
-    const Report *report = tvc->iter;
+    const Report *report = (const Report *)tvc->iter;
     tvc->iter_char_end = report->len;
     report_textview_init__internal(tvc);
 
@@ -134,14 +135,14 @@ static void report_textview_end(TextViewContext *UNUSED(tvc))
 static int report_textview_step(TextViewContext *tvc)
 {
   /* simple case, but no newline support */
-  const Report *report = tvc->iter;
+  const Report *report = (const Report *)tvc->iter;
 
   if (tvc->iter_char_begin <= 0) {
     tvc->iter = (void *)((Link *)tvc->iter)->prev;
     if (tvc->iter && report_textview_skip__internal(tvc)) {
       tvc->iter_tmp++;
 
-      report = tvc->iter;
+      report = (const Report *)tvc->iter;
       tvc->iter_char_end = report->len; /* reset start */
       report_textview_init__internal(tvc);
 
@@ -159,7 +160,7 @@ static int report_textview_step(TextViewContext *tvc)
 
 static void report_textview_line_get(TextViewContext *tvc, const char **r_line, int *r_len)
 {
-  const Report *report = tvc->iter;
+  const Report *report = (const Report *)tvc->iter;
   *r_line = report->message + tvc->iter_char_begin;
   *r_len = tvc->iter_char_end - tvc->iter_char_begin;
 }
@@ -200,7 +201,7 @@ static int info_textview_main__internal(const SpaceInfo *sinfo,
   tvc.step = report_textview_step;
   tvc.line_get = report_textview_line_get;
   tvc.line_data = report_line_data;
-  tvc.const_colors = NULL;
+  tvc.const_colors = nullptr;
 
   tvc.arg1 = sinfo;
   tvc.arg2 = reports;
@@ -225,21 +226,21 @@ void *info_text_pick(const SpaceInfo *sinfo,
                      const ReportList *reports,
                      int mouse_y)
 {
-  void *mval_pick_item = NULL;
+  void *mval_pick_item = nullptr;
   const int mval[2] = {0, mouse_y};
 
-  info_textview_main__internal(sinfo, region, reports, false, mval, &mval_pick_item, NULL);
+  info_textview_main__internal(sinfo, region, reports, false, mval, &mval_pick_item, nullptr);
   return (void *)mval_pick_item;
 }
 
 int info_textview_height(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports)
 {
   const int mval[2] = {INT_MAX, INT_MAX};
-  return info_textview_main__internal(sinfo, region, reports, false, mval, NULL, NULL);
+  return info_textview_main__internal(sinfo, region, reports, false, mval, nullptr, nullptr);
 }
 
 void info_textview_main(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports)
 {
   const int mval[2] = {INT_MAX, INT_MAX};
-  info_textview_main__internal(sinfo, region, reports, true, mval, NULL, NULL);
+  info_textview_main__internal(sinfo, region, reports, true, mval, nullptr, nullptr);
 }
diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.hh
similarity index 100%
rename from source/blender/editors/space_info/info_intern.h
rename to source/blender/editors/space_info/info_intern.hh
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.cc
similarity index 93%
rename from source/blender/editors/space_info/info_ops.c
rename to source/blender/editors/space_info/info_ops.cc
index 0583628be43..e7a4e18c789 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.cc
@@ -21,8 +21,8 @@
  * \ingroup spinfo
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
 
 #include "DNA_space_types.h"
 #include "DNA_windowmanager_types.h"
@@ -54,7 +54,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
-#include "info_intern.h"
+#include "info_intern.hh"
 
 /********************* pack blend file libraries operator *********************/
 
@@ -159,7 +159,7 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
   Image *ima;
 
   /* First check for dirty images. */
-  for (ima = bmain->images.first; ima; ima = ima->id.next) {
+  for (ima = (Image *)bmain->images.first; ima; ima = (Image *)ima->id.next) {
     if (BKE_image_is_dirty(ima)) {
       break;
     }
@@ -210,7 +210,7 @@ static const EnumPropertyItem unpack_all_method_items[] = {
     {PF_KEEP, "KEEP", 0, "Disable auto-pack, keep all packed files", ""},
     {PF_REMOVE, "REMOVE", 0, "Remove Pack", ""},
     /* {PF_ASK, "ASK", 0, "Ask for each file", ""}, */
-    {0, NULL, 0, NULL, NULL},
+    {0, nullptr, 0, nullptr, nullptr},
 };
 
 static int unpack_all_exec(bContext *C, wmOperator *op)
@@ -219,7 +219,8 @@ static int unpack_all_exec(bContext *C, wmOperator *op)
   int method = RNA_enum_get(op->ptr, "method");
 
   if (method != PF_KEEP) {
-    BKE_packedfile_unpack_all(bmain, op->reports, method); /* XXX PF_ASK can't work here */
+    BKE_packedfile_unpack_all(
+        bmain, op->reports, (enum ePF_FileStatus)method); /* XXX PF_ASK can't work here */
   }
   G.fileflags &= ~G_FILE_AUTOPACK;
 
@@ -299,7 +300,7 @@ static const EnumPropertyItem unpack_item_method_items[] = {
      "Write file to original location (overwrite existing file)",
      ""},
     /* {PF_ASK, "ASK", 0, "Ask for each file", ""}, */
-    {0, NULL, 0, NULL, NULL},
+    {0, nullptr, 0, nullptr, nullptr},
 };
 
 static int unpack_item_exec(bContext *C, wmOperator *op)
@@ -313,13 +314,14 @@ static int unpack_item_exec(bContext *C, wmOperator *op)
   RNA_string_get(op->ptr, "id_name", idname);
   id = BKE_libblock_find_name(bmain, type, idname);
 
-  if (id == NULL) {
+  if (id == nullptr) {
     BKE_report(op->reports, RPT_WARNING, "No packed file");
     return OPERATOR_CANCELLED;
   }
 
   if (method != PF_KEEP) {
-    BKE_packedfile_id_unpack(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */
+    BKE_packedfile_id_unpack(
+        bmain, id, op->reports, (enum ePF_FileStatus)method); /* XXX PF_ASK can't work here */
   }
 
   G.fileflags &= ~G_FILE_AUTOPACK;
@@ -336,7 +338,8 @@ static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED
   layout = UI_popup_menu_layout(pup);
 
   uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-  uiIt

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list