[Bf-blender-cvs] [039cc329178] master: Outliner: Compile all Outliner files in C++

Julian Eisel noreply at git.blender.org
Thu Jan 13 17:02:00 CET 2022


Commit: 039cc329178e9f7b14f514850479648c38fe1ea3
Author: Julian Eisel
Date:   Thu Jan 13 16:35:32 2022 +0100
Branches: master
https://developer.blender.org/rB039cc329178e9f7b14f514850479648c38fe1ea3

Outliner: Compile all Outliner files in C++

We want to refactor quite some of the Outliner code using C++, this is a
logical step to help the transition to a new architecture.

Includes plenty of fixes to make this compile without warnings, trying
not to change logic. The usual stuff (casts from `void *`, designated
initializers, compound literals, etc.).

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

M	source/blender/editors/space_outliner/CMakeLists.txt
R092	source/blender/editors/space_outliner/outliner_collections.c	source/blender/editors/space_outliner/outliner_collections.cc
R098	source/blender/editors/space_outliner/outliner_context.c	source/blender/editors/space_outliner/outliner_context.cc
R094	source/blender/editors/space_outliner/outliner_dragdrop.c	source/blender/editors/space_outliner/outliner_dragdrop.cc
R097	source/blender/editors/space_outliner/outliner_draw.c	source/blender/editors/space_outliner/outliner_draw.cc
R097	source/blender/editors/space_outliner/outliner_edit.c	source/blender/editors/space_outliner/outliner_edit.cc
R100	source/blender/editors/space_outliner/outliner_intern.h	source/blender/editors/space_outliner/outliner_intern.hh
R099	source/blender/editors/space_outliner/outliner_ops.c	source/blender/editors/space_outliner/outliner_ops.cc
R095	source/blender/editors/space_outliner/outliner_select.c	source/blender/editors/space_outliner/outliner_select.cc
R098	source/blender/editors/space_outliner/outliner_sync.c	source/blender/editors/space_outliner/outliner_sync.cc
R097	source/blender/editors/space_outliner/outliner_tools.c	source/blender/editors/space_outliner/outliner_tools.cc
R094	source/blender/editors/space_outliner/outliner_tree.c	source/blender/editors/space_outliner/outliner_tree.cc
R098	source/blender/editors/space_outliner/outliner_utils.c	source/blender/editors/space_outliner/outliner_utils.cc
R090	source/blender/editors/space_outliner/space_outliner.c	source/blender/editors/space_outliner/space_outliner.cc
M	source/blender/editors/space_outliner/tree/tree_display_data.cc
M	source/blender/editors/space_outliner/tree/tree_display_libraries.cc
M	source/blender/editors/space_outliner/tree/tree_display_orphaned.cc
M	source/blender/editors/space_outliner/tree/tree_display_override_library.cc
M	source/blender/editors/space_outliner/tree/tree_display_scenes.cc
M	source/blender/editors/space_outliner/tree/tree_display_sequencer.cc
M	source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
M	source/blender/editors/space_outliner/tree/tree_element_anim_data.cc
M	source/blender/editors/space_outliner/tree/tree_element_collection.cc
M	source/blender/editors/space_outliner/tree/tree_element_driver.cc
M	source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.cc
M	source/blender/editors/space_outliner/tree/tree_element_id.cc
M	source/blender/editors/space_outliner/tree/tree_element_id_library.cc
M	source/blender/editors/space_outliner/tree/tree_element_id_scene.cc
M	source/blender/editors/space_outliner/tree/tree_element_nla.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M	source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc
M	source/blender/editors/space_outliner/tree/tree_element_view_layer.cc
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/windowmanager/WM_types.h

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

diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index c31239f0e9c..5530a1e0416 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -34,18 +34,18 @@ set(INC
 
 
 set(SRC
-  outliner_collections.c
-  outliner_context.c
-  outliner_dragdrop.c
-  outliner_draw.c
-  outliner_edit.c
-  outliner_ops.c
-  outliner_select.c
-  outliner_sync.c
-  outliner_tools.c
-  outliner_tree.c
-  outliner_utils.c
-  space_outliner.c
+  outliner_collections.cc
+  outliner_context.cc
+  outliner_dragdrop.cc
+  outliner_draw.cc
+  outliner_edit.cc
+  outliner_ops.cc
+  outliner_select.cc
+  outliner_sync.cc
+  outliner_tools.cc
+  outliner_tree.cc
+  outliner_utils.cc
+  space_outliner.cc
   tree/common.cc
   tree/tree_display.cc
   tree/tree_display_data.cc
@@ -68,7 +68,7 @@ set(SRC
   tree/tree_element_scene_objects.cc
   tree/tree_element_view_layer.cc
 
-  outliner_intern.h
+  outliner_intern.hh
   tree/tree_display.h
   tree/tree_display.hh
   tree/tree_element.h
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.cc
similarity index 92%
rename from source/blender/editors/space_outliner/outliner_collections.c
rename to source/blender/editors/space_outliner/outliner_collections.cc
index 946d7a0538d..222191e50ee 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.cc
@@ -49,7 +49,7 @@
 #include "RNA_define.h"
 #include "RNA_enum_types.h"
 
-#include "outliner_intern.h" /* own include */
+#include "outliner_intern.hh" /* own include */
 
 /* -------------------------------------------------------------------- */
 /** \name Utility API
@@ -85,7 +85,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te)
   }
 
   if (tselem->type == TSE_LAYER_COLLECTION) {
-    LayerCollection *lc = te->directdata;
+    LayerCollection *lc = reinterpret_cast<LayerCollection *>(te->directdata);
     return lc->collection;
   }
   if (ELEM(tselem->type, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) {
@@ -101,7 +101,7 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te)
 
 TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *customdata)
 {
-  struct IDsSelectedData *data = customdata;
+  struct IDsSelectedData *data = reinterpret_cast<IDsSelectedData *>(customdata);
   TreeStoreElem *tselem = TREESTORE(te);
 
   if (outliner_is_collection_tree_element(te)) {
@@ -118,7 +118,7 @@ TreeTraversalAction outliner_find_selected_collections(TreeElement *te, void *cu
 
 TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *customdata)
 {
-  struct IDsSelectedData *data = customdata;
+  struct IDsSelectedData *data = reinterpret_cast<IDsSelectedData *>(customdata);
   TreeStoreElem *tselem = TREESTORE(te);
 
   if (outliner_is_collection_tree_element(te)) {
@@ -196,7 +196,7 @@ struct CollectionNewData {
 
 static TreeTraversalAction collection_find_selected_to_add(TreeElement *te, void *customdata)
 {
-  struct CollectionNewData *data = customdata;
+  struct CollectionNewData *data = reinterpret_cast<CollectionNewData *>(customdata);
   Collection *collection = outliner_collection_from_tree_element(te);
 
   if (!collection) {
@@ -220,10 +220,7 @@ static int collection_new_exec(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
 
-  struct CollectionNewData data = {
-      .error = false,
-      .collection = NULL,
-  };
+  CollectionNewData data{};
 
   if (RNA_boolean_get(op->ptr, "nested")) {
     outliner_build_tree(bmain, scene, view_layer, space_outliner, region);
@@ -295,7 +292,7 @@ struct CollectionEditData {
 
 static TreeTraversalAction collection_find_data_to_edit(TreeElement *te, void *customdata)
 {
-  struct CollectionEditData *data = customdata;
+  CollectionEditData *data = reinterpret_cast<CollectionEditData *>(customdata);
   Collection *collection = outliner_collection_from_tree_element(te);
 
   if (!collection) {
@@ -321,10 +318,9 @@ void outliner_collection_delete(
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
 
-  struct CollectionEditData data = {
-      .scene = scene,
-      .space_outliner = space_outliner,
-  };
+  CollectionEditData data{};
+  data.scene = scene;
+  data.space_outliner = space_outliner;
 
   data.collections_to_edit = BLI_gset_ptr_new(__func__);
 
@@ -336,7 +332,8 @@ void outliner_collection_delete(
   /* Effectively delete the collections. */
   GSetIterator collections_to_edit_iter;
   GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
-    Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
+    Collection *collection = reinterpret_cast<Collection *>(
+        BLI_gsetIterator_getKey(&collections_to_edit_iter));
 
     /* Test in case collection got deleted as part of another one. */
     if (BLI_findindex(&bmain->collections, collection) != -1) {
@@ -440,12 +437,12 @@ struct CollectionObjectsSelectData {
 static TreeTraversalAction outliner_find_first_selected_layer_collection(TreeElement *te,
                                                                          void *customdata)
 {
-  struct CollectionObjectsSelectData *data = customdata;
+  CollectionObjectsSelectData *data = reinterpret_cast<CollectionObjectsSelectData *>(customdata);
   TreeStoreElem *tselem = TREESTORE(te);
 
   switch (tselem->type) {
     case TSE_LAYER_COLLECTION:
-      data->layer_collection = te->directdata;
+      data->layer_collection = reinterpret_cast<LayerCollection *>(te->directdata);
       return TRAVERSE_BREAK;
     case TSE_R_LAYER:
     case TSE_SCENE_COLLECTION_BASE:
@@ -460,9 +457,7 @@ static LayerCollection *outliner_active_layer_collection(bContext *C)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
 
-  struct CollectionObjectsSelectData data = {
-      .layer_collection = NULL,
-  };
+  CollectionObjectsSelectData data{};
 
   outliner_tree_traverse(space_outliner,
                          &space_outliner->tree,
@@ -536,7 +531,7 @@ struct CollectionDuplicateData {
 static TreeTraversalAction outliner_find_first_selected_collection(TreeElement *te,
                                                                    void *customdata)
 {
-  struct CollectionDuplicateData *data = customdata;
+  CollectionDuplicateData *data = reinterpret_cast<CollectionDuplicateData *>(customdata);
   TreeStoreElem *tselem = TREESTORE(te);
 
   switch (tselem->type) {
@@ -555,9 +550,7 @@ static TreeElement *outliner_active_collection(bContext *C)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
 
-  struct CollectionDuplicateData data = {
-      .te = NULL,
-  };
+  CollectionDuplicateData data = {};
 
   outliner_tree_traverse(space_outliner,
                          &space_outliner->tree,
@@ -619,7 +612,8 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op)
                "it won't be linked to any view layer");
   }
 
-  const eDupli_ID_Flags dupli_flags = USER_DUP_OBJECT | (linked ? 0 : U.dupflag);
+  const eDupli_ID_Flags dupli_flags = (eDupli_ID_Flags)(USER_DUP_OBJECT |
+                                                        (linked ? 0 : U.dupflag));
   BKE_collection_duplicate(bmain, parent, collection, dupli_flags, LIB_ID_DUPLICATE_IS_ROOT_ID);
 
   DEG_relations_tag_update(bmain);
@@ -674,10 +668,10 @@ static int collection_link_exec(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   Collection *active_collection = CTX_data_layer_collection(C)->collection;
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
-  struct CollectionEditData data = {
-      .scene = scene,
-      .space_outliner = space_outliner,
-  };
+
+  CollectionEditData data{};
+  data.scene = scene;
+  data.space_outliner = space_outliner;
 
   if ((ID_IS_LINKED(active_collection) || ID_IS_OVERRIDE_LIBRARY(active_collection)) ||
       ((active_collection->flag & COLLECTION_IS_MASTER) &&
@@ -696,7 +690,8 @@ static int collection_link_exec(bContext *C, wmOperator *op)
   /* Effectively link the collections. */
   GSetIterator collections_to_edit_iter;
   GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
-    Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
+    Collection *collection = reinterpret_cast<Collection *>(
+        BLI_gsetIterator_getKey(&collections_to_edit_iter));
     BKE_collection_child_add(bmain, active_collection, collection);
     id_fake_user_clear(&collection->id);
   }
@@ -738,10 +733,9 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
   Scene *scene = CTX_data_scene(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
-  struct CollectionEditData data = {
-      .scene = scene,
-      .space_outliner = space_outliner,
-  };
+  CollectionEditData data{};
+  data.scene = scene;
+  data.space_outliner = space_outliner;
 
   data.collections_to_edit = BLI_gset_ptr_new(__func__);
 
@@ -755,7 +749,8 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
 
   GSetIterator collections_to_edit_iter;
   GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
-    Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
+    Collection *collection = reinterpret_cast<Collection *>(
+        BLI_gsetIterator_getKey(&collections_to_edit_iter));
 
     while (BKE_collection_cycle_find(active_lc->collection, collection)) {
       active_lc = BKE_layer_collection_activate_parent(view_layer, active_lc);
@@ -764,7 +759,8 @@ static int collection_instance_exec(bContext *C, wmOperator *UNUSED(op))
 
   /* Effectively instance the collections. */
   GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
-    Collection *collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
+    Collection *collection = reinterpret_cast<Collection *>(
+        BLI_gsetIterator_getKey(&collections_to_edit_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list