[Bf-blender-cvs] [6b6ea04] master: Macros: replace UNPACK#OP -> UNPACK#_EX, allow suffix

Campbell Barton noreply at git.blender.org
Tue Aug 5 00:15:01 CEST 2014


Commit: 6b6ea0485f3fee08f87af80caf8f7d3a2b3792cb
Author: Campbell Barton
Date:   Tue Aug 5 08:04:57 2014 +1000
Branches: master
https://developer.blender.org/rB6b6ea0485f3fee08f87af80caf8f7d3a2b3792cb

Macros: replace UNPACK#OP -> UNPACK#_EX, allow suffix

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

M	source/blender/blenlib/BLI_utildefines.h
M	source/blender/editors/interface/interface_regions.c

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

diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h
index 6a9eb64..683b3c4 100644
--- a/source/blender/blenlib/BLI_utildefines.h
+++ b/source/blender/blenlib/BLI_utildefines.h
@@ -379,13 +379,13 @@
 #define IN_RANGE_INCL(a, b, c) ((b < c) ? ((b <= a && a <= c) ? 1 : 0) : ((c <= a && a <= b) ? 1 : 0))
 
 /* unpack vector for args */
-#define UNPACK2(a)  ((a)[0]), ((a)[1])
-#define UNPACK3(a)  ((a)[0]), ((a)[1]), ((a)[2])
-#define UNPACK4(a)  ((a)[0]), ((a)[1]), ((a)[2]), ((a)[3])
-/* op may be '&' or '*' */
-#define UNPACK2OP(op, a)  op((a)[0]), op((a)[1])
-#define UNPACK3OP(op, a)  op((a)[0]), op((a)[1]), op((a)[2])
-#define UNPACK4OP(op, a)  op((a)[0]), op((a)[1]), op((a)[2]), op((a)[3])
+#define UNPACK2(a)  ((a)[0]),   ((a)[1])
+#define UNPACK3(a)  UNPACK2(a), ((a)[2])
+#define UNPACK4(a)  UNPACK3(a), ((a)[3])
+/* pre may be '&', '*' or func, post may be '->member' */
+#define UNPACK2_EX(pre, a, post)  (pre((a)[0])post),        (pre((a)[1])post)
+#define UNPACK3_EX(pre, a, post)  UNPACK2_EX(pre, a, post), (pre((a)[2])post)
+#define UNPACK4_EX(pre, a, post)  UNPACK3_EX(pre, a, post), (pre((a)[3])post)
 
 /* array helpers */
 #define ARRAY_LAST_ITEM(arr_start, arr_dtype, tot) \
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 32fb684..3629c72 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1872,7 +1872,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3], bool is
 			if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart);
 
 			rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma);
-			BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3OP((unsigned int), rgb_gamma_uchar));
+			BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((unsigned int), rgb_gamma_uchar, ));
 			
 			strcpy(bt->poin, col);
 		}
@@ -2160,7 +2160,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper
 	}
 
 	rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma);
-	BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3OP((unsigned int), rgb_gamma_uchar));
+	BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3_EX((unsigned int), rgb_gamma_uchar, ));
 
 	yco = -3.0f * UI_UNIT_Y;
 	bt = uiDefBut(block, TEX, 0, IFACE_("Hex: "), 0, yco, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, TIP_("Hex triplet for color (#RRGGBB)"));




More information about the Bf-blender-cvs mailing list