[Bf-blender-cvs] [16f06e9dc9f] blender2.8: Introduce "skip" in BLI_Iterator struct

Dalai Felinto noreply at git.blender.org
Mon Oct 30 22:34:58 CET 2017


Commit: 16f06e9dc9f9fe5fa05a3ad60bd29641c5ab4de7
Author: Dalai Felinto
Date:   Mon Oct 30 19:34:46 2017 -0200
Branches: blender2.8
https://developer.blender.org/rB16f06e9dc9f9fe5fa05a3ad60bd29641c5ab4de7

Introduce "skip" in BLI_Iterator struct

This helps iterators prevent recursion.

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

M	source/blender/blenlib/BLI_iterator.h

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

diff --git a/source/blender/blenlib/BLI_iterator.h b/source/blender/blenlib/BLI_iterator.h
index a2ec21d89b3..39d5cc12d87 100644
--- a/source/blender/blenlib/BLI_iterator.h
+++ b/source/blender/blenlib/BLI_iterator.h
@@ -30,6 +30,7 @@
 typedef struct BLI_Iterator {
 	void *current; /* current pointer we iterate over */
 	void *data;    /* stored data required for this iterator */
+	bool skip;
 	bool valid;
 } BLI_Iterator;
 
@@ -40,12 +41,18 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in);
 {                                                                                    \
 	_type _instance;                                                                 \
 	IteratorCb callback_end_func = callback_end;                                     \
-	BLI_Iterator iter_macro;                                                             \
+	BLI_Iterator iter_macro = {                                                      \
+		.skip = false,                                                               \
+	};                                                                               \
 	for (callback_begin(&iter_macro, (_data_in));                                    \
 	     iter_macro.valid;                                                           \
 	     callback_next(&iter_macro))                                                 \
-    {                                                                                \
-	    _instance = (_type ) iter_macro.current;
+	{                                                                                \
+		if (iter_macro.skip) {                                                       \
+			iter_macro.skip = false;                                                 \
+			continue;                                                                \
+		}                                                                            \
+		_instance = (_type ) iter_macro.current;
 
 #define ITER_END                                                                     \
 	}                                                                                \



More information about the Bf-blender-cvs mailing list