Commit: 90d317f161e3e73b5a30d90c74e6636b89bf7009
Author: Sergey Sharybin
Date:   Thu May 26 17:37:55 2016 +0200
Branches: depsgraph_cleanup
https://developer.blender.org/rB90d317f161e3e73b5a30d90c74e6636b89bf7009

Depsgraph: Add some utility macro to avoid long typecasts

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

M       source/blender/depsgraph/intern/builder/deg_builder.cc
M       source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
M       source/blender/depsgraph/intern/depsgraph.cc
M       source/blender/depsgraph/intern/depsgraph_debug.cc
M       source/blender/depsgraph/intern/depsgraph_tag.cc
M       source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M       source/blender/depsgraph/intern/nodes/deg_node.cc
M       source/blender/depsgraph/intern/nodes/deg_node_component.cc
M       source/blender/depsgraph/util/deg_util_foreach.h

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc 
b/source/blender/depsgraph/intern/builder/deg_builder.cc
index fddf0e4..4ed8352 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -108,9 +108,8 @@ void deg_graph_build_finalize(Depsgraph *graph)
        }
 
        /* Re-tag IDs for update if it was tagged before the relations update 
tag. */
-       GHashIterator gh_iter;
-       GHASH_ITER (gh_iter, graph->id_hash) {
-               IDDepsNode *id_node = reinterpret_cast<IDDepsNode 
*>(BLI_ghashIterator_getValue(&gh_iter));
+       GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash)
+       {
                ID *id = id_node->id;
                if (id->tag & LIB_TAG_ID_RECALC_ALL &&
                    id->tag & LIB_TAG_DOIT)
@@ -119,6 +118,7 @@ void deg_graph_build_finalize(Depsgraph *graph)
                        id->tag &= ~LIB_TAG_DOIT;
                }
        }
+       GHASH_FOREACH_END();
 }
 
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc 
b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
index a9f2185..c49387b 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc
@@ -370,11 +370,11 @@ static void deg_debug_graphviz_node(const DebugContext 
&ctx,
                        }
                        else {
                                deg_debug_graphviz_node_cluster_begin(ctx, 
node);
-                               GHashIterator gh_iter;
-                               GHASH_ITER (gh_iter, id_node->components) {
-                                       const ComponentDepsNode *comp = 
reinterpret_cast<const ComponentDepsNode 
*>(BLI_ghashIterator_getValue(&gh_iter));
+                               GHASH_FOREACH_BEGIN(const ComponentDepsNode *, 
comp, id_node->components)
+                               {
                                        deg_debug_graphviz_node(ctx, comp);
                                }
+                               GHASH_FOREACH_END();
                                deg_debug_graphviz_node_cluster_end(ctx);
                        }
                        break;
@@ -405,11 +405,11 @@ static void deg_debug_graphviz_node(const DebugContext 
&ctx,
                {
                        ComponentDepsNode *comp_node = (ComponentDepsNode 
*)node;
                        if (BLI_ghash_size(comp_node->operations) > 0) {
-                               GHashIterator gh_iter;
-                               GHASH_ITER (gh_iter, comp_node->operations) {
-                                       const DepsNode *op_node = 
reinterpret_cast<const DepsNode *>(BLI_ghashIterator_getValue(&gh_iter));
+                               GHASH_FOREACH_BEGIN(const DepsNode *, op_node, 
comp_node->operations)
+                               {
                                        deg_debug_graphviz_node(ctx, op_node);
                                }
+                               GHASH_FOREACH_END();
                                deg_debug_graphviz_node_cluster_end(ctx);
                        }
                        else {
@@ -519,11 +519,11 @@ static void deg_debug_graphviz_graph_nodes(const 
DebugContext &ctx,
        if (graph->root_node) {
                deg_debug_graphviz_node(ctx, graph->root_node);
        }
-       GHashIterator gh_iter;
-       GHASH_ITER (gh_iter, graph->id_hash) {
-               DepsNode *node = reinterpret_cast<DepsNode 
*>(BLI_ghashIterator_getValue(&gh_iter));
+       GHASH_FOREACH_BEGIN (DepsNode *, node, graph->id_hash)
+       {
                deg_debug_graphviz_node(ctx, node);
        }
+       GHASH_FOREACH_END();
        TimeSourceDepsNode *time_source = graph->find_time_source(NULL);
        if (time_source != NULL) {
                deg_debug_graphviz_node(ctx, time_source);
@@ -533,19 +533,19 @@ static void deg_debug_graphviz_graph_nodes(const 
DebugContext &ctx,
 static void deg_debug_graphviz_graph_relations(const DebugContext &ctx,
                                                const Depsgraph *graph)
 {
-       GHashIterator gh_iter;
-       GHASH_ITER (gh_iter, graph->id_hash) {
-               IDDepsNode *id_node = reinterpret_cast<IDDepsNode 
*>(BLI_ghashIterator_getValue(&gh_iter));
-               GHashIterator gh_comp_iter;
-               GHASH_ITER (gh_comp_iter, id_node->components) {
-                       ComponentDepsNode *comp_node = 
reinterpret_cast<ComponentDepsNode 
*>(BLI_ghashIterator_getValue(&gh_comp_iter));
-                       GHashIterator gh_op_iter;
-                       GHASH_ITER (gh_op_iter, comp_node->operations) {
-                               OperationDepsNode *op_node = 
reinterpret_cast<OperationDepsNode *>(BLI_ghashIterator_getValue(&gh_op_iter));
+       GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash)
+       {
+               GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, 
id_node->components)
+               {
+                       GHASH_FOREACH_BEGIN(OperationDepsNode *, op_node, 
comp_node->operations)
+                       {
                                deg_debug_graphviz_node_relations(ctx, op_node);
                        }
+                       GHASH_FOREACH_END();
                }
+               GHASH_FOREACH_END();
        }
+       GHASH_FOREACH_END();
 
        TimeSourceDepsNode *time_source = graph->find_time_source(NULL);
        if (time_source != NULL) {
diff --git a/source/blender/depsgraph/intern/depsgraph.cc 
b/source/blender/depsgraph/intern/depsgraph.cc
index 3739b08..8207ea6 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -309,11 +309,11 @@ void Depsgraph::remove_subgraph_node(SubgraphDepsNode 
*subgraph_node)
 
 void Depsgraph::clear_subgraph_nodes()
 {
-       GSetIterator gs_iter;
-       GSET_ITER (gs_iter, subgraphs) {
-               SubgraphDepsNode *subgraph_node = 
reinterpret_cast<SubgraphDepsNode *>(BLI_gsetIterator_getKey(&gs_iter));
+       GSET_FOREACH_BEGIN(SubgraphDepsNode *, subgraph_node, subgraphs)
+       {
                OBJECT_GUARDED_DELETE(subgraph_node, SubgraphDepsNode);
        }
+       GSET_FOREACH_END();
        BLI_gset_clear(subgraphs, NULL);
 }
 
@@ -347,11 +347,11 @@ void Depsgraph::remove_id_node(const ID *id)
 
 void Depsgraph::clear_id_nodes()
 {
-       GHashIterator gh_iter;
-       GHASH_ITER (gh_iter, id_hash) {
-               IDDepsNode *id_node = reinterpret_cast<IDDepsNode 
*>(BLI_ghashIterator_getValue(&gh_iter));
+       GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash)
+       {
                OBJECT_GUARDED_DELETE(id_node, IDDepsNode);
        }
+       GHASH_FOREACH_END();
        BLI_ghash_clear(id_hash, NULL, NULL);
 }
 
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc 
b/source/blender/depsgraph/intern/depsgraph_debug.cc
index 1758b23..1be70ad 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -218,21 +218,21 @@ void DEG_stats_simple(const Depsgraph *graph, size_t 
*r_outer,
                size_t tot_outer = 0;
                size_t tot_rels = 0;
 
-               GHashIterator gh_iter;
-               GHASH_ITER (gh_iter, deg_graph->id_hash) {
-                       DEG::IDDepsNode *id_node = 
reinterpret_cast<DEG::IDDepsNode *>(BLI_ghashIterator_getValue(&gh_iter));
+               GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, 
deg_graph->id_hash)
+               {
                        tot_outer++;
-                       GHashIterator gh_comp_iter;
-                       GHASH_ITER (gh_iter, id_node->components) {
-                               DEG::ComponentDepsNode *comp_node = 
reinterpret_cast<DEG::ComponentDepsNode 
*>(BLI_ghashIterator_getValue(&gh_comp_iter));
+                       GHASH_FOREACH_BEGIN(DEG::ComponentDepsNode *, 
comp_node, id_node->components)
+                       {
                                tot_outer++;
-                               GHashIterator gh_op_iter;
-                               GHASH_ITER (gh_op_iter, comp_node->operations) {
-                                       DEG::OperationDepsNode *op_node = 
reinterpret_cast<DEG::OperationDepsNode 
*>(BLI_ghashIterator_getValue(&gh_op_iter));
+                               GHASH_FOREACH_BEGIN(DEG::OperationDepsNode *, 
op_node, comp_node->operations)
+                               {
                                        tot_rels += op_node->inlinks.size();
                                }
+                               GHASH_FOREACH_END();
                        }
+                       GHASH_FOREACH_END();
                }
+               GHASH_FOREACH_END();
 
                DEG::TimeSourceDepsNode *time_source = 
deg_graph->find_time_source(NULL);
                if (time_source != NULL) {
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc 
b/source/blender/depsgraph/intern/depsgraph_tag.cc
index abdffec..ea5afaa 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -314,9 +314,8 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
                 * This is mainly needed on file load only, after that updates 
of invisible objects
                 * will be stored in the pending list.
                 */
-               GHashIterator gh_iter;
-               GHASH_ITER (gh_iter, graph->id_hash) {
-                       DEG::IDDepsNode *id_node = 
reinterpret_cast<DEG::IDDepsNode *>(BLI_ghashIterator_getValue(&gh_iter));
+               GHASH_FOREACH_BEGIN(DEG::IDDepsNode *, id_node, graph->id_hash)
+               {
                        ID *id = id_node->id;
                        if ((id->tag & LIB_TAG_ID_RECALC_ALL) != 0 ||
                            (id_node->layers & scene->lay_updated) == 0)
@@ -342,6 +341,7 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
                                }
                        }
                }
+               GHASH_FOREACH_END();
        }
        scene->lay_updated |= graph->layers;
 }
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc 
b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index 726da76..7883847 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -119,9 +119,8 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
         * NOTE: Count how many nodes we need to handle - entry nodes may be
         *       component nodes which don't count for this purpose!
         */
-       GSetIterator gs_iter;
-       GSET_ITER (gs_iter, graph->entry_tags) {
-               OperationDepsNode *node = reinterpret_cast<OperationDepsNode 
*>(BLI_gsetIterator_getKey(&gs_iter));
+       GSET_FOREACH_BEGIN(OperationDepsNode *, node, graph->entry_tags)
+       {
                IDDepsNode *id_node = node->owner->owner;
                queue.push(node);
                if (id_node->done == 0) {
@@ -130,6 +129,7 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
                }
                node->scheduled = true;
        }
+       GSET_FOREACH_END();
 
        while (!queue.empty()) {
                OperationDepsNode *node = queue.front();
@@ -181,11 +181,11 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph 
*graph)
                 */
                ComponentDepsNode *component = node->owner;
                if ((component->flags & DEPSCOMP_FULLY_SCHEDULED) == 0) {
-                       GHashIterator gh_iter;
-                       GHASH_ITER (gh_iter, component->operations) {
-                               OperationDepsNode *op = 
reinterpret_cast<OperationDepsNode *>(BLI_ghashIterator_getValue(&gh_iter));
+                       GHASH_FOREACH_BEGIN(OperationDepsNode *, op, 
component->operations)
+                       {
                                op->flag |= DEPSOP_FLAG_NEEDS_UPDATE;
                        }
+                       GHASH_FOREACH_END();
                        component->flags |= DEPSCOMP_FULLY_SCHEDULED;
                }
        }
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc 
b/source/blender/depsgraph/intern/nodes/deg_node.cc
index 6f85578..5e6672d 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node.cc
@@ -228,19 +228,18 @@ void IDDepsNode::remove_component(eDepsNode_Type type, 
const string &name)
 
 void IDDepsNode::clear_components()
 {
-       GHashIterator gh_iter;
-       GHASH_ITER (gh_iter, components) {
-               ComponentDepsNode *comp_node = 
reinterpret_cast<ComponentDepsNode *>(BLI_ghashIterator_getValue(&gh_iter));
+       GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components)

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to