[Bf-blender-cvs] [832a97f] master: Macros: ELEM() can now take 2 args

Campbell Barton noreply at git.blender.org
Sun Nov 16 14:31:07 CET 2014


Commit: 832a97f00270ad6d5740d3b8938d82269760964e
Author: Campbell Barton
Date:   Sun Nov 16 14:29:17 2014 +0100
Branches: master
https://developer.blender.org/rB832a97f00270ad6d5740d3b8938d82269760964e

Macros: ELEM() can now take 2 args

Handy when used indirectly.

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

M	source/blender/blenlib/BLI_utildefines.h

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

diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index f318ae0..16d3c2f 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -51,7 +51,7 @@
 	_49_, _50_, _51_, _52_, _53_, _54_, _55_, _56_, _57_, _58_, _59_, _60_, _61_, _62_, _63_, _64_, \
 	count, ...) count
 #define _VA_NARGS_EXPAND(args) _VA_NARGS_RETURN_COUNT args
-#define _VA_NARGS_COUNT_MAX32(...) _VA_NARGS_EXPAND((__VA_ARGS__, \
+#define _VA_NARGS_COUNT_MAX64(...) _VA_NARGS_EXPAND((__VA_ARGS__, \
 	64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, \
 	48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, \
 	32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, \
@@ -61,7 +61,7 @@
 #define _VA_NARGS_OVERLOAD_MACRO(name,  count) _VA_NARGS_OVERLOAD_MACRO1(name, count)
 /* --- expose for re-use --- */
 #define VA_NARGS_CALL_OVERLOAD(name, ...) \
-	_VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, _VA_NARGS_COUNT_MAX32(__VA_ARGS__)), (__VA_ARGS__))
+	_VA_NARGS_GLUE(_VA_NARGS_OVERLOAD_MACRO(name, _VA_NARGS_COUNT_MAX64(__VA_ARGS__)), (__VA_ARGS__))
 
 /* useful for finding bad use of min/max */
 #if 0
@@ -179,8 +179,10 @@
 
 /* ELEM#(v, ...): is the first arg equal any others? */
 /* internal helpers*/
+#define _VA_ELEM2(v, a) \
+       ((v) == (a))
 #define _VA_ELEM3(v, a, b) \
-       (((v) == (a)) || ((v) == (b)))
+       (_VA_ELEM2(v, a) || ((v) == (b)))
 #define _VA_ELEM4(v, a, b, c) \
        (_VA_ELEM3(v, a, b) || ((v) == (c)))
 #define _VA_ELEM5(v, a, b, c, d) \




More information about the Bf-blender-cvs mailing list