[Bf-blender-cvs] [b19c51c7f42] master: Cleanup: Move outliner types to namespace, avoid C-style type definition

Julian Eisel noreply at git.blender.org
Wed Aug 24 20:11:28 CEST 2022


Commit: b19c51c7f42ea8940ff456a4b3945e905c4e3d5a
Author: Julian Eisel
Date:   Wed Aug 24 19:45:48 2022 +0200
Branches: master
https://developer.blender.org/rBb19c51c7f42ea8940ff456a4b3945e905c4e3d5a

Cleanup: Move outliner types to namespace, avoid C-style type definition

With C++ we should transition towards namespaces to avoid naming
collisions. Having the namespace in place is the first step for that
transition.

Plus, the `typedef` isn't necessary for struct/class/enum definitions
in C++, so avoid the verbosity it adds.

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

M	source/blender/editors/space_outliner/outliner_collections.cc
M	source/blender/editors/space_outliner/outliner_context.cc
M	source/blender/editors/space_outliner/outliner_dragdrop.cc
M	source/blender/editors/space_outliner/outliner_draw.cc
M	source/blender/editors/space_outliner/outliner_edit.cc
M	source/blender/editors/space_outliner/outliner_intern.hh
M	source/blender/editors/space_outliner/outliner_ops.cc
M	source/blender/editors/space_outliner/outliner_query.cc
M	source/blender/editors/space_outliner/outliner_select.cc
M	source/blender/editors/space_outliner/outliner_sync.cc
M	source/blender/editors/space_outliner/outliner_tools.cc
M	source/blender/editors/space_outliner/outliner_tree.cc
M	source/blender/editors/space_outliner/outliner_utils.cc
M	source/blender/editors/space_outliner/space_outliner.cc
M	source/blender/editors/space_outliner/tree/common.cc
M	source/blender/editors/space_outliner/tree/common.hh
M	source/blender/editors/space_outliner/tree/tree_display.hh
M	source/blender/editors/space_outliner/tree/tree_element.hh
M	source/blender/editors/space_outliner/tree/tree_element_anim_data.hh
M	source/blender/editors/space_outliner/tree/tree_element_driver.hh
M	source/blender/editors/space_outliner/tree/tree_iterator.hh
M	source/blender/makesdna/DNA_space_types.h

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

diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc
index 02d54e4f702..836ad3e3f93 100644
--- a/source/blender/editors/space_outliner/outliner_collections.cc
+++ b/source/blender/editors/space_outliner/outliner_collections.cc
@@ -38,6 +38,8 @@
 
 #include "outliner_intern.hh" /* own include */
 
+namespace blender::ed::outliner {
+
 /* -------------------------------------------------------------------- */
 /** \name Utility API
  * \{ */
@@ -122,8 +124,12 @@ TreeTraversalAction outliner_find_selected_objects(TreeElement *te, void *custom
   return TRAVERSE_CONTINUE;
 }
 
+}  // namespace blender::ed::outliner
+
 void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
 {
+  using namespace blender::ed::outliner;
+
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
   struct IDsSelectedData data = {{nullptr}};
   outliner_tree_traverse(space_outliner,
@@ -140,12 +146,16 @@ void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
   BLI_freelistN(&data.selected_array);
 }
 
+namespace blender::ed::outliner {
+
 /** \} */
 
 /* -------------------------------------------------------------------- */
 /** \name Poll Functions
  * \{ */
 
+}  // namespace blender::ed::outliner
+
 bool ED_outliner_collections_editor_poll(bContext *C)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
@@ -153,6 +163,8 @@ bool ED_outliner_collections_editor_poll(bContext *C)
          ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES);
 }
 
+namespace blender::ed::outliner {
+
 static bool outliner_view_layer_collections_editor_poll(bContext *C)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
@@ -1636,3 +1648,5 @@ void OUTLINER_OT_collection_color_tag_set(wmOperatorType *ot)
 }
 
 /** \} */
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/outliner_context.cc b/source/blender/editors/space_outliner/outliner_context.cc
index 1a804cb58b8..001bda57fa2 100644
--- a/source/blender/editors/space_outliner/outliner_context.cc
+++ b/source/blender/editors/space_outliner/outliner_context.cc
@@ -14,7 +14,7 @@
 #include "outliner_intern.hh"
 #include "tree/tree_iterator.hh"
 
-using namespace blender::ed::outliner;
+namespace blender::ed::outliner {
 
 static void outliner_context_selected_ids_recursive(const SpaceOutliner &space_outliner,
                                                     bContextDataResult *result)
@@ -55,3 +55,5 @@ int /*eContextResult*/ outliner_context(const bContext *C,
 
   return CTX_RESULT_MEMBER_NOT_FOUND;
 }
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc
index 2fa512b4006..81224fb6a2b 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.cc
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc
@@ -45,6 +45,8 @@
 
 #include "outliner_intern.hh"
 
+namespace blender::ed::outliner {
+
 static Collection *collection_parent_from_ID(ID *id);
 
 /* -------------------------------------------------------------------- */
@@ -1592,3 +1594,5 @@ void outliner_dropboxes(void)
 }
 
 /** \} */
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index 3201d8bc3a3..7004f4cec61 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -74,8 +74,7 @@
 #include "tree/tree_element_rna.hh"
 #include "tree/tree_iterator.hh"
 
-using namespace blender;
-using namespace blender::ed::outliner;
+namespace blender::ed::outliner {
 
 /* -------------------------------------------------------------------- */
 /** \name Tree Size Functions
@@ -3994,3 +3993,5 @@ void draw_outliner(const bContext *C)
 }
 
 /** \} */
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc
index 37008889d06..712684624f7 100644
--- a/source/blender/editors/space_outliner/outliner_edit.cc
+++ b/source/blender/editors/space_outliner/outliner_edit.cc
@@ -65,6 +65,8 @@
 
 using namespace blender::ed::outliner;
 
+namespace blender::ed::outliner {
+
 static void outliner_show_active(SpaceOutliner *space_outliner,
                                  ARegion *region,
                                  TreeElement *te,
@@ -2230,3 +2232,5 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot)
 }
 
 /** \} */
+
+}  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh
index 684d665ff3d..47b3dbe6152 100644
--- a/source/blender/editors/space_outliner/outliner_intern.hh
+++ b/source/blender/editors/space_outliner/outliner_intern.hh
@@ -14,10 +14,6 @@
 /* Needed for `tree_element_cast()`. */
 #include "tree/tree_element.hh"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /* internal exports only */
 
 struct ARegion;
@@ -27,7 +23,6 @@ struct ListBase;
 struct Main;
 struct Object;
 struct Scene;
-struct TreeElement;
 struct TreeStoreElem;
 struct ViewLayer;
 struct bContext;
@@ -37,22 +32,23 @@ struct View2D;
 struct wmKeyConfig;
 struct wmOperatorType;
 
-namespace blender::ed::outliner {
-class AbstractTreeDisplay;
-class AbstractTreeElement;
-}  // namespace blender::ed::outliner
-
 namespace blender::bke::outliner::treehash {
 class TreeHash;
 }
 
-namespace outliner = blender::ed::outliner;
+namespace blender::ed::outliner {
+
+class AbstractTreeDisplay;
+class AbstractTreeElement;
+
 namespace treehash = blender::bke::outliner::treehash;
 
+struct TreeElement;
+
 struct SpaceOutliner_Runtime {
   /** Object to create and manage the tree for a specific display type (View Layers, Scenes,
    * Blender File, etc.). */
-  std::unique_ptr<outliner::AbstractTreeDisplay> tree_display;
+  std::unique_ptr<AbstractTreeDisplay> tree_display;
 
   /* Hash table for tree-store elements, using `(id, type, index)` as key. */
   std::unique_ptr<treehash::TreeHash> tree_hash;
@@ -63,25 +59,25 @@ struct SpaceOutliner_Runtime {
   ~SpaceOutliner_Runtime() = default;
 };
 
-typedef enum TreeElementInsertType {
+enum TreeElementInsertType {
   TE_INSERT_BEFORE,
   TE_INSERT_AFTER,
   TE_INSERT_INTO,
-} TreeElementInsertType;
+};
 
-typedef enum TreeTraversalAction {
+enum TreeTraversalAction {
   /** Continue traversal regularly, don't skip children. */
   TRAVERSE_CONTINUE = 0,
   /** Stop traversal. */
   TRAVERSE_BREAK,
   /** Continue traversal, but skip children of traversed element. */
   TRAVERSE_SKIP_CHILDS,
-} TreeTraversalAction;
+};
 
-typedef TreeTraversalAction (*TreeTraversalFunc)(struct TreeElement *te, void *customdata);
+typedef TreeTraversalAction (*TreeTraversalFunc)(TreeElement *te, void *customdata);
 
-typedef struct TreeElement {
-  struct TreeElement *next, *prev, *parent;
+struct TreeElement {
+  TreeElement *next, *prev, *parent;
 
   /**
    * The new inheritance based representation of the element (a derived type of base
@@ -89,7 +85,7 @@ typedef struct TreeElement {
    * be moved to it and operations based on the type should become virtual methods of the class
    * hierarchy.
    */
-  std::unique_ptr<outliner::AbstractTreeElement> abstract_element;
+  std::unique_ptr<AbstractTreeElement> abstract_element;
 
   ListBase subtree;
   int xs, ys;                /* Do selection. */
@@ -100,12 +96,12 @@ typedef struct TreeElement {
   short xend;                /* Width of item display, for select. */
   const char *name;
   void *directdata; /* Armature Bones, Base, ... */
-} TreeElement;
+};
 
-typedef struct TreeElementIcon {
+struct TreeElementIcon {
   struct ID *drag_id, *drag_parent;
   int icon;
-} TreeElementIcon;
+};
 
 #define TREESTORE_ID_TYPE(_id) \
   (ELEM(GS((_id)->name), \
@@ -172,17 +168,17 @@ enum {
 /* button events */
 #define OL_NAMEBUTTON 1
 
-typedef enum {
+enum eOLDrawState {
   OL_DRAWSEL_NONE = 0,   /* inactive (regular black text) */
   OL_DRAWSEL_NORMAL = 1, /* active object (draws white text) */
   OL_DRAWSEL_ACTIVE = 2, /* active obdata (draws a circle around the icon) */
-} eOLDrawState;
+};
 
-typedef enum {
+enum eOLSetState {
   OL_SETSEL_NONE = 0,   /* don't change the selection state */
   OL_SETSEL_NORMAL = 1, /* select the item */
   OL_SETSEL_EXTEND = 2, /* select the item and extend (also toggles selection) */
-} eOLSetState;
+};
 
 /* get TreeStoreElem associated with a TreeElement
  * < a: (TreeElement) tree element to find stored element for
@@ -232,7 +228,7 @@ typedef enum {
  * Container to avoid passing around these variables to many functions.
  * Also so we can have one place to assign these variables.
  */
-typedef struct TreeViewContext {
+struct TreeViewContext {
   /* Scene level. */
   struct Scene *scene;
   struct ViewLayer *view_layer;
@@ -245,16 +241,16 @@ typedef struct TreeViewContext {
    * The pose object may not be the active object (when in weight paint mode).
    * Checking this in draw loops isn't efficient, so set only once. */
   Object *ob_pose;
-} TreeViewContext;
+};
 
-typedef enum TreeItemSelectAction {
+enum TreeItemSelectAction {
   OL_ITEM_DESELECT = 0,           /* Deselect the item */
   OL_ITEM_SELECT = (1 << 0),      /* Select the item */
   OL_ITEM_SELECT_DATA = (1 << 1), /* Select object data */
   OL_ITEM_ACTIVATE = (1 << 2),    /* Activate the item */
   OL_ITEM_EXTEND = (1 << 3),      /* Extend the current selection */
   OL_ITEM_RECURSIVE = (1 << 4),   /* Select recursively */
-} TreeItemSelectAction;
+};
 
 /* outliner_tree.c ----------------------------------------------- */
 
@@ -277,9 +273,9 @@ void outliner_build_tree(struct Main *mainvar,
                          struct SpaceOutliner *space_outliner,
                          struct ARegion *region);
 
-struct TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
-                                                      struct Collection *collection,
-                      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list